Skip to content

Commit 3bbace3

Browse files
feat[array]: dynamic expr execute (#5714)
Signed-off-by: Joe Isaacs <[email protected]>
1 parent bf4e84e commit 3bbace3

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

vortex-array/src/expr/exprs/dynamic.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ use vortex_error::vortex_bail;
1616
use vortex_scalar::Scalar;
1717
use vortex_scalar::ScalarValue;
1818
use vortex_vector::Datum;
19+
use vortex_vector::Scalar as VectorScalar;
20+
use vortex_vector::bool::BoolScalar;
1921

2022
use crate::Array;
2123
use crate::ArrayRef;
@@ -24,6 +26,7 @@ use crate::arrays::ConstantArray;
2426
use crate::compute::Operator;
2527
use crate::compute::compare;
2628
use crate::expr::Arity;
29+
use crate::expr::Binary;
2730
use crate::expr::ChildName;
2831
use crate::expr::ExecutionArgs;
2932
use crate::expr::ExprId;
@@ -115,8 +118,26 @@ impl VTable for DynamicComparison {
115118
.into_array())
116119
}
117120

118-
fn execute(&self, _data: &Self::Options, _args: ExecutionArgs) -> VortexResult<Datum> {
119-
todo!()
121+
fn execute(&self, data: &Self::Options, args: ExecutionArgs) -> VortexResult<Datum> {
122+
if let Some(scalar) = data.rhs.scalar() {
123+
let [lhs]: [Datum; _] = args
124+
.datums
125+
.try_into()
126+
.map_err(|_| vortex_error::vortex_err!("Wrong arg count for DynamicComparison"))?;
127+
let rhs_vector_scalar = scalar.to_vector_scalar();
128+
let rhs = Datum::Scalar(rhs_vector_scalar);
129+
130+
return Binary.bind(data.operator.into()).execute(ExecutionArgs {
131+
datums: vec![lhs, rhs],
132+
dtypes: args.dtypes,
133+
row_count: args.row_count,
134+
return_dtype: args.return_dtype,
135+
});
136+
}
137+
138+
Ok(Datum::Scalar(VectorScalar::Bool(BoolScalar::new(Some(
139+
data.default,
140+
)))))
120141
}
121142

122143
fn stat_falsification(

0 commit comments

Comments
 (0)