{"record":{"id":"9b17227e574c97e7","repo":"influxdata/influxdb","slug":"expected-array-value","errorCode":null,"errorMessage":"Expected array value","messagePattern":"Expected array value","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/query_functions/src/date_bin_wallclock.rs","lineNumber":757,"sourceCode":"            ))),\n            ColumnarValue::Array(arr),\n        ];\n        let arg_fields = arg_to_fields(&args);\n        let result = match udf\n            .invoke_with_args(ScalarFunctionArgs {\n                args,\n                arg_fields,\n                number_rows: 3,\n                return_field: return_field(DataType::Timestamp(\n                    TimeUnit::Nanosecond,\n                    Some(Arc::from(\"Europe/Paris\")),\n                )),\n                config_options: default_config_options(),\n            })\n            .unwrap()\n        {\n            ColumnarValue::Array(arr) => as_timestamp_nanosecond_array(&arr).unwrap().clone(),\n            _ => panic!(\"Expected array value\"),\n        };\n        assert_eq!(\n            result,\n            TimestampNanosecondArray::from(vec![\n                Some(MAYDAY - 2 * 60 * 60 * 1_000_000_000),\n                None,\n                Some(MAYDAY + 22 * 60 * 60 * 1_000_000_000),\n            ])\n            .with_timezone(\"Europe/Paris\")\n        );\n    }\n\n    #[test]\n    fn array_interval_error() {\n        let udf = DateBinWallclockUDF::default();\n        let tz = Arc::from(\"UTC\");\n        let arr = Arc::new(IntervalMonthDayNanoArray::from(vec![\n            Some(IntervalMonthDayNano {","sourceCodeStart":739,"sourceCodeEnd":775,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/query_functions/src/date_bin_wallclock.rs#L739-L775","documentation":"A test panic in the `array_value` test of date_bin_wallclock.rs. The test expects the UDF to return ColumnarValue::Array when given array inputs, downcasts it to a TimestampNanosecondArray, and panics with \"Expected array value\" if a Scalar is returned instead.","triggerScenarios":"Calling date_bin_wallclock with array source values (including a null) and matching ColumnarValue::Array; the panic fires when the implementation collapses the result to a scalar or returns the wrong variant.","commonSituations":"Occurs when an optimization shortcut returns a scalar for uniform array inputs, or when array/null handling is refactored and the array path is bypassed.","solutions":["Reproduce with `cargo test -p query_functions date_bin_wallclock::tests::array_value`.","Ensure the implementation returns ColumnarValue::Array whenever any argument is an array, preserving nulls.","If the return is intentionally scalar-folded, change the test to build the expected array from the scalar."],"exampleFix":"// before\nColumnarValue::Array(arr) => as_timestamp_nanosecond_array(&arr).unwrap().clone(),\n_ => panic!(\"Expected array value\"),\n// after\nColumnarValue::Array(arr) => as_timestamp_nanosecond_array(&arr).unwrap().clone(),\nColumnarValue::Scalar(s) => panic!(\"expected array value, got scalar: {:?}\", s),","handlingStrategy":"type-guard","validationCode":"assert!(matches!(result, ColumnarValue::Array(_)), \"array inputs must produce array output\");","typeGuard":"fn expect_array(v: ColumnarValue) -> ArrayRef {\n    match v { ColumnarValue::Array(a) => a, ColumnarValue::Scalar(s) => panic!(\"expected array, got scalar {:?}\", s) }\n}","tryCatchPattern":"let arr = match result {\n    ColumnarValue::Array(a) => a,\n    ColumnarValue::Scalar(s) => panic!(\"expected array value, got scalar {:?}\", s),\n};","preventionTips":["Preserve null semantics when refactoring array handling in UDFs","Never scalar-fold array inputs unless explicitly documented and tested","Add a match arm that names the unexpected variant in panic messages"],"tags":["rust","test-panic","unit-test","array-value"],"backgroundTag":"type-mismatch","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}