diff --git a/vortex-array/src/scalar_fn/fns/dynamic.rs b/vortex-array/src/scalar_fn/fns/dynamic.rs index 64ad27ca3a0..c18b75a3354 100644 --- a/vortex-array/src/scalar_fn/fns/dynamic.rs +++ b/vortex-array/src/scalar_fn/fns/dynamic.rs @@ -152,6 +152,11 @@ impl DynamicComparisonExpr { self.default } + /// The dtype of the dynamic value, whether or not the value is known yet. + pub fn dtype(&self) -> &DType { + &self.rhs.dtype + } + /// A comparison against the same dynamic value with a different operator and default. pub fn with_operator(&self, operator: CompareOperator, default: bool) -> Self { Self { @@ -358,6 +363,16 @@ mod tests { assert!(!expr.as_scalar().is_some_and(|f| f.signature().is_strict())); } + #[test] + fn dtype_of_unknown_value() { + let dtype = DType::Primitive(PType::I32, Nullability::NonNullable); + let expr = dynamic(CompareOperator::Lt, || None, dtype.clone(), true, root()); + + let options = expr.as_::(); + assert_eq!(options.scalar(), None); + assert_eq!(options.dtype(), &dtype); + } + #[test] fn return_dtype_bool() -> VortexResult<()> { let expr = dynamic(