{"record":{"id":"28f576f8789fd6d0","repo":"risingwavelabs/risingwave","slug":"array-error-0-28f576","errorCode":null,"errorMessage":"Array error: {0}","messagePattern":"Array error: (.+?)","errorType":"exception","errorClass":"ExprError","httpStatus":null,"severity":"error","filePath":"src/expr/core/src/error.rs","lineNumber":81,"sourceCode":"\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(\n        #[from]\n        #[backtrace]\n        ArrayError,\n    ),\n\n    #[error(\"More than one row returned by {0} used as an expression\")]\n    MaxOneRow(&'static str),\n\n    /// TODO: deprecate in favor of `Function`\n    #[error(transparent)]\n    Internal(\n        #[from]\n        #[backtrace]\n        anyhow::Error,\n    ),\n\n    #[error(\"not a constant\")]","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/expr/core/src/error.rs#L63-L99","documentation":"ExprError::Array wraps ArrayError (via `#[from]`) with the message 'Array error: {0}'. It surfaces lower-level array-type failures (dimension mismatches, index out of bounds on array construction/access, invalid array literal) as expression-evaluation errors. Because it uses `#[from]`, any `ArrayError` returned inside expression code is converted automatically.","triggerScenarios":"Evaluating array expressions whose shapes/dimensions don't match (e.g. building a multi-dimensional array from ragged sub-arrays), array subscript access beyond the array length, parsing malformed ARRAY literals like `ARRAY[1,2,'a']` under strict typing.","commonSituations":"Queries mixing 1-D and 2-D arrays, indexing arrays with positions beyond their size, ingesting JSON/protobuf data converted to arrays with inconsistent nesting.","solutions":["Check array dimensions/length before subscripting, e.g. with `cardinality(arr)` or `array_length`.","Use a bounds-safe access such as `arr[idx]` only after verifying idx <= cardinality, or coalesce with a default.","Normalize nested arrays to a consistent shape before array construction."],"exampleFix":"// before\nSELECT arr[5] FROM t; -- arr has length 3\n// after\nSELECT CASE WHEN cardinality(arr) >= 5 THEN arr[5] ELSE NULL END FROM t;","handlingStrategy":"validation","validationCode":"-- bounds check before array access\nSELECT CASE WHEN i <= cardinality(arr) THEN arr[i] ELSE NULL END FROM t;","typeGuard":null,"tryCatchPattern":"// Downcast to the wrapped ArrayError for structured handling\nif let Some(ExprError::Array(inner)) = err.downcast_ref::<ExprError>() {\n    log::warn!(\"array failure: {inner}\");\n    return Ok(default);\n}","preventionTips":["Check cardinality/array_length before subscripting.","Keep nested array shapes consistent; normalize before construction.","Test array expressions against empty and ragged arrays."],"tags":["rust","array","streaming"],"backgroundTag":"index-out-of-bounds","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"}