influxdata/influxdb · error
Expected timestamp data type
Error message
Expected timestamp data type
What it means
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.
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.
Example fix
// before
let DataType::Timestamp(_, tz) = source.data_type() else {
panic!("Expected timestamp data type");
};
// after
let DataType::Timestamp(_, tz) = source.data_type() else {
panic!("expected timestamp data type, got {:?}", source.data_type());
}; Defensive patterns
Strategy: validation
Validate before calling
assert!(matches!(source.data_type(), DataType::Timestamp(_, Some(_))), "source must be a timestamp with tz, got {:?}", source.data_type()); Type guard
fn as_timestamp_tz(dt: &DataType) -> Option<&Option<Arc<str>>> {
match dt { DataType::Timestamp(_, tz) => Some(tz), _ => None }
} Try / catch
let DataType::Timestamp(_, tz) = source.data_type() else {
panic!("expected timestamp data type, got {:?}", source.data_type());
}; Prevention
- 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
When it happens
Trigger: 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.
Common situations: Happens after changing test literals without casting to TimestampNanosecond, or after DataFusion coercion changes that no longer force timestamp types before invocation.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Expected three arguments
- Error computing AND
- Expected array value
- expected bucket id, got string
- expected bucket id, got TS range
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/c8b4aba7d53f04f8.
Report an issue: GitHub.
Appendix: source
Thrown at core/query_functions/src/date_bin_wallclock.rs:931
fn name(&self) -> &'static str {
"test_date_bin_udf"
}
fn signature(&self) -> &Signature {
&self.signature
}
fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
Ok(arg_types[1].clone())
}
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
let [_, source, origin] = args.args.as_slice() else {
panic!("Expected three arguments");
};
assert_eq!(source.data_type(), origin.data_type());
let DataType::Timestamp(_, tz) = source.data_type() else {
panic!("Expected timestamp data type");
};
assert!(tz.is_some());
Ok(source.clone())
}
}
fn arg_to_fields(args: &[ColumnarValue]) -> Vec<FieldRef> {
args.iter()
.enumerate()
.map(|(idx, val)| Arc::new(Field::new(format!("arg_{idx}"), val.data_type(), false)))
.collect()
}
fn return_field(dt: DataType) -> FieldRef {
Arc::new(Field::new("r", dt, false))
}
}
View on GitHub (pinned to 06200ef96b)