Skip to content

Commit 86b48b5

Browse files
committed
wip
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent bc92ead commit 86b48b5

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

vortex-array/src/compute/boolean.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ use vortex_error::VortexResult;
99

1010
use crate::Array;
1111
use crate::ArrayRef;
12+
use crate::IntoArray;
13+
use crate::arrays::ScalarFnArray;
1214
use crate::arrow::FromArrowArray;
1315
use crate::arrow::IntoArrowArray;
1416
use crate::compute::Options;
17+
use crate::expr::Binary;
18+
use crate::expr::ScalarFn;
19+
use crate::expr::operators::Operator;
1520

1621
/// Point-wise logical _and_ between two Boolean arrays.
1722
///
@@ -52,7 +57,12 @@ pub fn or_kleene(lhs: &dyn Array, rhs: &dyn Array) -> VortexResult<ArrayRef> {
5257
/// This method uses Arrow-style null propagation rather than the Kleene logic semantics. This
5358
/// semantics is also known as "Bochvar logic" and "weak Kleene logic".
5459
pub fn boolean(lhs: &dyn Array, rhs: &dyn Array, op: BooleanOperator) -> VortexResult<ArrayRef> {
55-
arrow_boolean(lhs.to_array(), rhs.to_array(), op)
60+
Ok(ScalarFnArray::try_new(
61+
ScalarFn::new(Binary, Operator::try_from(op)?),
62+
vec![lhs.to_array(), rhs.to_array()],
63+
lhs.len(),
64+
)?
65+
.into_array())
5666
}
5767

5868
/// Operations over the nullable Boolean values.

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,17 @@ impl TryInto<compute::Operator> for Operator {
213213
})
214214
}
215215
}
216+
217+
impl TryFrom<compute::BooleanOperator> for Operator {
218+
type Error = VortexError;
219+
220+
fn try_from(value: compute::BooleanOperator) -> VortexResult<Self> {
221+
match value {
222+
compute::BooleanOperator::AndKleene => Ok(Operator::And),
223+
compute::BooleanOperator::OrKleene => Ok(Operator::Or),
224+
other => vortex_bail!(
225+
"Non-Kleene boolean operator {other:?} cannot be represented as an expression Operator"
226+
),
227+
}
228+
}
229+
}

0 commit comments

Comments
 (0)