Skip to content

Commit 6043a57

Browse files
authored
fix: unblock the fuzzers (#5335)
#5271 wasn't quite right actually for file_io array_ops was broken on what I believe to be an unnecessary assertion --------- Signed-off-by: Andrew Duffy <[email protected]>
1 parent 8bc0df8 commit 6043a57

File tree

3 files changed

+25
-37
lines changed

3 files changed

+25
-37
lines changed

vortex-array/src/arrays/listview/array.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,6 @@ impl ListViewArray {
221221
// Check that the size type can fit within the offset type to prevent overflows.
222222
let size_ptype = sizes.dtype().as_ptype();
223223
let offset_ptype = offsets.dtype().as_ptype();
224-
let size_max = sizes.dtype().as_ptype().max_value_as_u64();
225-
let offset_max = offsets.dtype().as_ptype().max_value_as_u64();
226-
227-
vortex_ensure!(
228-
size_max <= offset_max,
229-
"size type {:?} (max {}) must fit within offset type {:?} (max {})",
230-
size_ptype,
231-
size_max,
232-
offset_ptype,
233-
offset_max
234-
);
235224

236225
// If a validity array is present, it must be the same length as the `ListViewArray`.
237226
if let Some(validity_len) = validity.maybe_len() {

vortex-array/src/arrays/listview/tests/basic.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -266,20 +266,6 @@ fn test_validate_nullable_sizes() {
266266
);
267267
}
268268

269-
#[test]
270-
fn test_validate_size_type_too_large() {
271-
// Logical lists (invalid due to size type > offset type): [[1,2], [3], [2,3]]
272-
let elements = buffer![1i32, 2, 3, 4, 5].into_array();
273-
// Use u64 for sizes and u32 for offsets (sizes type is larger).
274-
let offsets = buffer![0u32, 2, 1].into_array();
275-
let sizes = buffer![2u64, 1, 2].into_array();
276-
277-
let result = ListViewArray::try_new(elements, offsets, sizes, Validity::NonNullable);
278-
279-
assert!(result.is_err());
280-
assert!(result.unwrap_err().to_string().contains("size type"));
281-
}
282-
283269
#[test]
284270
fn test_validate_offset_plus_size_overflow() {
285271
// Logical lists (invalid due to overflow): would overflow, [[1], [1]]

vortex-array/src/compute/compare.rs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::fmt::{Display, Formatter};
77
use std::sync::LazyLock;
88

99
use arcref::ArcRef;
10-
use arrow_array::{BooleanArray, Datum as ArrowDatum};
10+
use arrow_array::BooleanArray;
1111
use arrow_buffer::NullBuffer;
1212
use arrow_ord::cmp;
1313
use arrow_ord::ord::make_comparator;
@@ -18,7 +18,7 @@ use vortex_error::{VortexError, VortexExpect, VortexResult, vortex_bail, vortex_
1818
use vortex_scalar::Scalar;
1919

2020
use crate::arrays::ConstantArray;
21-
use crate::arrow::{Datum, from_arrow_array_with_len};
21+
use crate::arrow::{Datum, IntoArrowArray, from_arrow_array_with_len};
2222
use crate::compute::{ComputeFn, ComputeFnVTable, InvocationArgs, Kernel, Options, Output};
2323
use crate::vtable::VTable;
2424
use crate::{Array, ArrayRef, Canonical, IntoArray};
@@ -295,17 +295,12 @@ fn arrow_compare(
295295
operator: Operator,
296296
) -> VortexResult<ArrayRef> {
297297
assert_eq!(left.len(), right.len());
298-
let len = left.len();
299298

300299
let nullable = left.dtype().is_nullable() || right.dtype().is_nullable();
301300

302301
let array = if left.dtype().is_nested() || right.dtype().is_nested() {
303-
let rhs = Datum::try_new_array(&right.to_canonical().into_array())?;
304-
let (rhs, _) = rhs.get();
305-
306-
// prefer the rhs data type since this is usually used in assert_eq!(actual, expect).
307-
let lhs = Datum::with_target_datatype(&left.to_canonical().into_array(), rhs.data_type())?;
308-
let (lhs, _) = lhs.get();
302+
let rhs = right.to_array().into_arrow_preferred()?;
303+
let lhs = left.to_array().into_arrow(rhs.data_type())?;
309304

310305
assert!(
311306
lhs.data_type().equals_datatype(rhs.data_type()),
@@ -314,7 +309,8 @@ fn arrow_compare(
314309
rhs.data_type()
315310
);
316311

317-
let cmp = make_comparator(lhs, rhs, SortOptions::default())?;
312+
let cmp = make_comparator(lhs.as_ref(), rhs.as_ref(), SortOptions::default())?;
313+
let len = left.len();
318314
let values = (0..len)
319315
.map(|i| {
320316
let cmp = cmp(i, i);
@@ -366,13 +362,14 @@ pub fn scalar_cmp(lhs: &Scalar, rhs: &Scalar, operator: Operator) -> Scalar {
366362
#[cfg(test)]
367363
mod tests {
368364
use rstest::rstest;
365+
use vortex_buffer::buffer;
369366
use vortex_dtype::{FieldName, FieldNames};
370367

371368
use super::*;
372369
use crate::ToCanonical;
373370
use crate::arrays::{
374-
BoolArray, ConstantArray, ListArray, PrimitiveArray, StructArray, VarBinArray,
375-
VarBinViewArray,
371+
BoolArray, ConstantArray, ListArray, ListViewArray, PrimitiveArray, StructArray,
372+
VarBinArray, VarBinViewArray,
376373
};
377374
use crate::test_harness::to_int_indices;
378375
use crate::validity::Validity;
@@ -600,4 +597,20 @@ mod tests {
600597
assert!(result.bit_buffer().value(idx));
601598
}
602599
}
600+
601+
#[test]
602+
fn test_empty_list() {
603+
let list = ListViewArray::new(
604+
BoolArray::from_iter(Vec::<bool>::new()).into_array(),
605+
buffer![0i32, 0i32, 0i32].into_array(),
606+
buffer![0i32, 0i32, 0i32].into_array(),
607+
Validity::AllValid,
608+
);
609+
610+
// Compare two lists together
611+
let result = compare(list.as_ref(), list.as_ref(), Operator::Eq).unwrap();
612+
assert!(result.scalar_at(0).is_valid());
613+
assert!(result.scalar_at(1).is_valid());
614+
assert!(result.scalar_at(2).is_valid());
615+
}
603616
}

0 commit comments

Comments
 (0)