Skip to content

Commit

Permalink
Return nice vorex-y error when trying to compare arrays with Struct d…
Browse files Browse the repository at this point in the history
…type (#1912)
  • Loading branch information
AdamGS authored Jan 13, 2025
1 parent 5a58bfa commit 1487e78
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 3 additions & 5 deletions vortex-array/src/array/chunked/compute/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,17 @@ impl CompareFn<ChunkedArray> for ChunkedEncoding {
mod tests {

use super::*;
use crate::array::StructArray;
use crate::validity::Validity;
use crate::array::PrimitiveArray;

#[test]
fn empty_compare() {
let base = StructArray::try_new([].into(), [].into(), 0, Validity::NonNullable)
.unwrap()
.into_array();
let base = PrimitiveArray::from_iter(Vec::<u32>::new()).into_array();
let chunked =
ChunkedArray::try_new(vec![base.clone(), base.clone()], base.dtype().clone()).unwrap();
let chunked_empty = ChunkedArray::try_new(vec![], base.dtype().clone()).unwrap();

let r = compare(&chunked, &chunked_empty, Operator::Eq).unwrap();

assert!(r.is_empty());
}
}
8 changes: 8 additions & 0 deletions vortex-array/src/compute/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ pub fn compare(
vortex_bail!("Compare operations only support arrays of the same type");
}

if left.dtype().is_struct() {
vortex_bail!(
"Compare does not support arrays with Strcut DType, got: {} and {}",
left.dtype(),
right.dtype()
)
}

let result_dtype =
DType::Bool((left.dtype().is_nullable() || right.dtype().is_nullable()).into());

Expand Down

0 comments on commit 1487e78

Please sign in to comment.