{"record":{"id":"cc7a847f5a82df01","repo":"risingwavelabs/risingwave","slug":"numeric-out-of-range-overflow","errorCode":null,"errorMessage":"Numeric out of range: overflow","messagePattern":"Numeric out of range: overflow","errorType":"exception","errorClass":"ExprError","httpStatus":null,"severity":"error","filePath":"src/expr/core/src/error.rs","lineNumber":64,"sourceCode":"\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 {\n        name: &'static str,\n        reason: Box<str>,\n    },\n\n    #[error(\"Array error: {0}\")]\n    Array(","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/expr/core/src/error.rs#L46-L82","documentation":"ExprError::NumericOutOfRange variant: a numeric computation or conversion produced a value above the maximum representable for the target type during expression evaluation (e.g. integer arithmetic overflow, decimal conversion). It is a generic sentinel raised wherever expression evaluation detects positive out-of-range results.","triggerScenarios":"Evaluating arithmetic (e.g. large multiplication, exponent-like growth via repeated ops) or casts where the result exceeds the target type's upper bound during expression evaluation.","commonSituations":"Multiplying large integer columns; cumulative aggregations exceeding int64/decimal bounds; casting wide numerics into narrower types over real datasets.","solutions":["Widen the result/intermediate type (e.g. decimal with more precision)","Use checked/try variants (try_cast) to tolerate overflow","Refactor arithmetic to reduce intermediate magnitude","Validate input magnitudes before computation"],"exampleFix":"// before\nSELECT col::int FROM t; -- exceeds i32 max\n// after\nSELECT try_cast(col as bigint) FROM t;","handlingStrategy":"validation","validationCode":"// pre-check upper bound before narrowing\nif v > max_allowed { /* clamp or NULL before cast */ }","typeGuard":null,"tryCatchPattern":"match eval_result {\n    Err(e) if e.to_string().contains(\"overflow\") => {\n        // widen type (e.g. bigint/decimal) and re-run\n    }\n    r => r,\n}","preventionTips":["Use try_cast for risky casts","Choose result types sized for worst-case growth","Monitor aggregations for approaching type limits"],"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"}