{"record":{"id":"daa6c1fa0986172b","repo":"influxdata/influxdb","slug":"expected-scalar-value","errorCode":null,"errorMessage":"Expected scalar value","messagePattern":"Expected scalar value","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/query_functions/src/date_bin_wallclock.rs","lineNumber":556,"sourceCode":"            ))),\n            ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(\n                Some(MAYDAY + 60 * 60 * 1_000_000_000),\n                None,\n            )),\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: 13,\n                return_field: return_field(DataType::Timestamp(TimeUnit::Nanosecond, None)),\n                config_options: default_config_options(),\n            })\n            .unwrap()\n        {\n            ColumnarValue::Scalar(scalar) => scalar,\n            _ => panic!(\"Expected scalar value\"),\n        };\n        assert_eq!(result, ScalarValue::TimestampNanosecond(Some(MAYDAY), None),);\n    }\n\n    #[test]\n    fn scalar_value_with_timezone() {\n        let udf = DateBinWallclockUDF::default();\n        let tz = Arc::from(\"America/New_York\");\n        let args = vec![\n            ColumnarValue::Scalar(ScalarValue::IntervalMonthDayNano(Some(\n                IntervalMonthDayNano::new(0, 1, 0),\n            ))),\n            ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(\n                Some(MAYDAY + 60 * 60 * 1_000_000_000),\n                Some(Arc::clone(&tz)),\n            )),\n        ];\n        let arg_fields = arg_to_fields(&args);","sourceCodeStart":538,"sourceCodeEnd":574,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/query_functions/src/date_bin_wallclock.rs#L538-L574","documentation":"Panic in the scalar_value_passthrough test of date_bin_wallclock: the date_bin wallclock UDF is documented/expected to return a ColumnarValue::Scalar when given scalar inputs, so any other variant (ColumnarValue::Array) is a contract violation and the test panics.","triggerScenarios":"Calling date_bin_wallclock's invoke with scalar timestamp and interval arguments and receiving ColumnarValue::Array instead of ColumnarValue::Scalar — i.e. the function implementation stopped special-casing scalar inputs.","commonSituations":"Refactoring the UDF's invoke to always return arrays; a DataFusion ScalarUDF trait version change altering how scalar-only calls are represented; forgetting the scalar fast-path after adding timezone support.","solutions":["Ensure the UDF's invoke has a scalar fast-path that returns ColumnarValue::Scalar when all inputs are scalars","Check the interval argument is a ScalarValue and not accidentally converted to an array upstream","Compare against the DataFusion version's ColumnarValue semantics for scalar UDFs","If behavior is intentionally array-only, update the test expectation rather than the function"],"exampleFix":"// before (UDF invoke)\nColumnarValue::Array(...)  // always array\n// after\nif args.iter().all(|a| matches!(a, ColumnarValue::Scalar(_))) {\n    ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(Some(binned), tz.clone()))\n} else {\n    ColumnarValue::Array(...)\n}","handlingStrategy":"type-guard","validationCode":"// Rust: verify UDF returns scalar for scalar-only args before unwrapping\nfn returns_scalar(v: &ColumnarValue) -> bool { matches!(v, ColumnarValue::Scalar(_)) }","typeGuard":"fn expect_scalar(v: ColumnarValue) -> Option<ScalarValue> {\n    match v { ColumnarValue::Scalar(s) => Some(s), _ => None }\n}","tryCatchPattern":"let scalar = match result {\n    ColumnarValue::Scalar(s) => s,\n    other => panic!(\"Expected scalar value, got: {other:?}\"),\n};","preventionTips":["Keep a scalar fast-path in UDF invoke implementations","Test both scalar and array invocation modes of each UDF","Match ColumnarValue exhaustively rather than assuming a variant","Check DataFusion release notes for ScalarUDF/ColumnarValue semantic changes"],"tags":["rust","datafusion","udf","test-panic"],"backgroundTag":"unexpected-response-shape","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"}