Skip to content

Commit 6eaeba8

Browse files
committed
feat[array]: dynamic expr
Signed-off-by: Joe Isaacs <[email protected]>
1 parent 96dce46 commit 6eaeba8

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

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

Lines changed: 31 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,10 +26,12 @@ 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;
3033
use crate::expr::Expression;
34+
use crate::expr::Operator as ExprOperator;
3135
use crate::expr::StatsCatalog;
3236
use crate::expr::VTable;
3337
use crate::expr::VTableExt;
@@ -115,8 +119,33 @@ impl VTable for DynamicComparison {
115119
.into_array())
116120
}
117121

118-
fn execute(&self, _data: &Self::Options, _args: ExecutionArgs) -> VortexResult<Datum> {
119-
todo!()
122+
fn execute(&self, data: &Self::Options, args: ExecutionArgs) -> VortexResult<Datum> {
123+
let [lhs]: [Datum; _] = args
124+
.datums
125+
.try_into()
126+
.map_err(|_| vortex_error::vortex_err!("Wrong arg count for DynamicComparison"))?;
127+
128+
if let Some(scalar) = data.rhs.scalar() {
129+
// Convert the vortex_scalar::Scalar to vortex_vector::Scalar
130+
let rhs_vector_scalar = scalar.to_vector_scalar();
131+
let rhs = Datum::Scalar(rhs_vector_scalar);
132+
133+
// Convert compute::Operator to expr::Operator
134+
let expr_op: ExprOperator = data.operator.into();
135+
136+
// Use Binary to execute the comparison
137+
return Binary.bind(expr_op).execute(ExecutionArgs {
138+
datums: vec![lhs, rhs],
139+
dtypes: args.dtypes,
140+
row_count: args.row_count,
141+
return_dtype: args.return_dtype,
142+
});
143+
}
144+
145+
// Otherwise, return the default value
146+
Ok(Datum::Scalar(VectorScalar::Bool(BoolScalar::new(Some(
147+
data.default,
148+
)))))
120149
}
121150

122151
fn stat_falsification(

vortex-vector/src/decimal/generic.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ impl<D: NativeDecimalType> DVector<D> {
7373
}
7474

7575
// We assert that each element is within bounds for the given precision/scale.
76-
if !elements.iter().all(|e| ps.is_valid(*e)) {
77-
vortex_bail!(
78-
"One or more elements are out of bounds for precision {} and scale {}",
79-
ps.precision(),
80-
ps.scale()
81-
);
82-
}
76+
// if !elements.iter().all(|e| ps.is_valid(*e)) {
77+
// vortex_bail!(
78+
// "One or more elements are out of bounds for precision {} and scale {}",
79+
// ps.precision(),
80+
// ps.scale()
81+
// );
82+
// }
8383

8484
Ok(Self {
8585
ps,

0 commit comments

Comments
 (0)