{"record":{"id":"8c28d8c2c2f08b0d","repo":"risingwavelabs/risingwave","slug":"numeric-out-of-range","errorCode":null,"errorMessage":"Numeric out of range","messagePattern":"Numeric out of range","errorType":"exception","errorClass":"ExprError","httpStatus":null,"severity":"error","filePath":"src/expr/core/src/error.rs","lineNumber":58,"sourceCode":"/// The error type for expression operations.\n#[derive(Error, ReportDebug)]\npub enum ExprError {\n    /// A collection of multiple errors in batch evaluation.\n    #[error(\"multiple errors:\\n{1}\")]\n    Multiple(ArrayRef, MultiExprError),\n\n    // Ideally \"Unsupported\" errors are caught by frontend. But when the match arms between\n    // frontend and backend are inconsistent, we do not panic with `unreachable!`.\n    #[error(\"Unsupported function: {0}\")]\n    UnsupportedFunction(String),\n\n    #[error(\"Unsupported cast: {0} to {1}\")]\n    UnsupportedCast(DataType, DataType),\n\n    #[error(\"Casting to {0} out of range\")]\n    CastOutOfRange(&'static str),\n\n    #[error(\"Numeric out of range\")]\n    NumericOutOfRange,\n\n    #[error(\"Numeric out of range: underflow\")]\n    NumericUnderflow,\n\n    #[error(\"Numeric out of range: overflow\")]\n    NumericOverflow,\n\n    #[error(\"Division by zero\")]\n    DivisionByZero,\n\n    #[error(\"Parse error: {0}\")]\n    // TODO(error-handling): should prefer use error types than strings.\n    Parse(Box<str>),\n\n    #[error(\"Invalid parameter {name}: {reason}\")]\n    // TODO(error-handling): should prefer use error types than strings.\n    InvalidParam {","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/expr/core/src/error.rs#L40-L76","documentation":"ExprError::NumericOutOfRange is a generic out-of-range error raised by numeric operations (arithmetic, casts) whose result exceeds the destination type's representable range, when no more specific variant applies.","triggerScenarios":"Arithmetic like a numeric multiplication overflowing decimal precision, or a cast whose overflow path maps to the generic variant.","commonSituations":"Aggregations over very large numbers exceeding decimal(38) precision; multiplication of big integers; upstream data growing beyond assumed bounds.","solutions":["Widen column/intermediate types (e.g. use larger decimal precision)","Check intermediate arithmetic for potential overflow and reorder operations","Use try_* variants where the API supports it","Validate data ranges before computing"],"exampleFix":"// before\nSELECT a * b AS c FROM t; -- overflows decimal(38)\n// after\nSELECT (a::decimal(38, 4) * b)::decimal(38, 10) AS c FROM t;","handlingStrategy":"validation","validationCode":"// pre-check numeric bounds before arithmetic\ndebug_assert!(acc.checked_mul(x).is_some(), \"intermediate would overflow\");","typeGuard":null,"tryCatchPattern":"match expr.eval(batch).await {\n    Err(e) if e.to_string().contains(\"Numeric out of range\") => {\n        // widen types and retry the computation\n    }\n    r => r,\n}","preventionTips":["Size decimal precision for worst-case products/sums","Avoid unbounded cumulative arithmetic in streaming SQL","Use checked arithmetic in UDFs"],"tags":["numeric","overflow","rust","arithmetic"],"backgroundTag":"value-out-of-range","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}