Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More specialized compare functions #488

Merged
merged 27 commits into from
Jul 22, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
This is more correct
AdamGS committed Jul 19, 2024
commit 6257749e075ab66809fc95fac79c3dfdc10fc02c
24 changes: 13 additions & 11 deletions vortex-array/src/array/constant/compute.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::cmp::Ordering;

use vortex_error::VortexResult;
use vortex_dtype::Nullability;
use vortex_error::{vortex_bail, VortexResult};
use vortex_scalar::Scalar;

use crate::array::constant::ConstantArray;
use crate::array::null::NullArray;
use crate::compute::boolean::{and, AndFn, OrFn};
use crate::compute::unary::scalar_at::ScalarAtFn;
use crate::compute::{ArrayCompute, SliceFn, TakeFn};
@@ -93,19 +93,21 @@ fn constant_array_bool_impl(
let lhs = constant_array.scalar().value().as_bool()?;
let rhs = array.scalar().value().as_bool()?;

let r = match lhs.zip(rhs).map(bool_op) {
Some(b) => ConstantArray::new(b, constant_array.len()).into_array(),
None => NullArray::new(constant_array.len()).into_array(),
let scalar = match lhs.zip(rhs).map(bool_op) {
Some(b) => Scalar::bool(b, Nullability::Nullable),
None => Scalar::null(constant_array.dtype().as_nullable()),
};

return Ok(r);
Ok(ConstantArray::new(scalar, constant_array.len()).into_array())
} else {
let lhs = constant_array.clone().into_bool()?;
let rhs = other.clone().into_bool()?;

and(lhs.as_array_ref(), rhs.as_array_ref())
}
} else {
vortex_bail!("Boolean operations aren't supported on arrays of different lengths")
}

let lhs = constant_array.clone().into_bool()?;
let rhs = other.clone().into_bool()?;

and(lhs.as_array_ref(), rhs.as_array_ref())
}

#[cfg(test)]