{"record":{"id":"c8b4aba7d53f04f8","repo":"influxdata/influxdb","slug":"expected-timestamp-data-type","errorCode":null,"errorMessage":"Expected timestamp data type","messagePattern":"Expected timestamp data type","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/query_functions/src/date_bin_wallclock.rs","lineNumber":931,"sourceCode":"        fn name(&self) -> &'static str {\n            \"test_date_bin_udf\"\n        }\n\n        fn signature(&self) -> &Signature {\n            &self.signature\n        }\n\n        fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {\n            Ok(arg_types[1].clone())\n        }\n\n        fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {\n            let [_, source, origin] = args.args.as_slice() else {\n                panic!(\"Expected three arguments\");\n            };\n            assert_eq!(source.data_type(), origin.data_type());\n            let DataType::Timestamp(_, tz) = source.data_type() else {\n                panic!(\"Expected timestamp data type\");\n            };\n            assert!(tz.is_some());\n            Ok(source.clone())\n        }\n    }\n\n    fn arg_to_fields(args: &[ColumnarValue]) -> Vec<FieldRef> {\n        args.iter()\n            .enumerate()\n            .map(|(idx, val)| Arc::new(Field::new(format!(\"arg_{idx}\"), val.data_type(), false)))\n            .collect()\n    }\n\n    fn return_field(dt: DataType) -> FieldRef {\n        Arc::new(Field::new(\"r\", dt, false))\n    }\n}\n","sourceCodeStart":913,"sourceCodeEnd":949,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/query_functions/src/date_bin_wallclock.rs#L913-L949","documentation":"A panic in the same test mock ScalarUDF's `invoke_with_args` in date_bin_wallclock.rs. After confirming three arguments, it destructures the source argument's DataType; if it is not DataType::Timestamp (with a timezone), it panics with \"Expected timestamp data type\". It validates that the UDF under test receives timestamp-typed source and origin arguments.","triggerScenarios":"The mock UDF is invoked where source.data_type() is not a Timestamp — e.g. the test passes Int64 or Null-typed literals, or return_type/type-coercion changes propagate a different type.","commonSituations":"Happens after changing test literals without casting to TimestampNanosecond, or after DataFusion coercion changes that no longer force timestamp types before invocation.","solutions":["Ensure the test's source/origin expressions are explicitly typed as Timestamp(_, Some(tz)) (use ScalarValue::TimestampNanosecond with a timezone or .cast_to).","Verify the mock's return_type/coercion signatures still force timestamp inputs.","Print source.data_type() at the panic to identify the unexpected type."],"exampleFix":"// before\nlet DataType::Timestamp(_, tz) = source.data_type() else {\n    panic!(\"Expected timestamp data type\");\n};\n// after\nlet DataType::Timestamp(_, tz) = source.data_type() else {\n    panic!(\"expected timestamp data type, got {:?}\", source.data_type());\n};","handlingStrategy":"validation","validationCode":"assert!(matches!(source.data_type(), DataType::Timestamp(_, Some(_))), \"source must be a timestamp with tz, got {:?}\", source.data_type());","typeGuard":"fn as_timestamp_tz(dt: &DataType) -> Option<&Option<Arc<str>>> {\n    match dt { DataType::Timestamp(_, tz) => Some(tz), _ => None }\n}","tryCatchPattern":"let DataType::Timestamp(_, tz) = source.data_type() else {\n    panic!(\"expected timestamp data type, got {:?}\", source.data_type());\n};","preventionTips":["Explicitly cast test literals to TimestampNanosecond with a timezone","Keep mock return_type/coercion signatures forcing timestamp inputs","Check coercion behavior after DataFusion version upgrades"],"tags":["rust","test-panic","type-mismatch","mock-udf"],"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"}