Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions vortex-array/src/scalar_fn/fns/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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_::<DynamicComparison>();
assert_eq!(options.scalar(), None);
assert_eq!(options.dtype(), &dtype);
}

#[test]
fn return_dtype_bool() -> VortexResult<()> {
let expr = dynamic(
Expand Down