use std::sync::LazyLock;
use rstest::rstest;
use vortex_array::ArrayRef;
use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::VortexSessionExecute;
use vortex_array::arrays::Bool;
use vortex_array::arrays::BoolArray;
use vortex_array::arrays::Chunked;
use vortex_array::arrays::ChunkedArray;
use vortex_array::arrays::ConstantArray;
use vortex_array::arrays::DecimalArray;
use vortex_array::arrays::Dict;
use vortex_array::arrays::DictArray;
use vortex_array::arrays::FilterArray;
use vortex_array::arrays::FixedSizeListArray;
use vortex_array::arrays::ListArray;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::arrays::ScalarFn;
use vortex_array::arrays::ScalarFnArray;
use vortex_array::arrays::StructArray;
use vortex_array::arrays::VarBinViewArray;
use vortex_array::arrays::chunked::ChunkedArrayExt;
use vortex_array::arrays::dict::DictArraySlotsExt;
use vortex_array::arrays::scalar_fn::ScalarFnArrayExt;
use vortex_array::assert_arrays_eq;
use vortex_array::builders::builder_with_capacity_in;
use vortex_array::dtype::DType;
use vortex_array::dtype::DecimalDType;
use vortex_array::dtype::Nullability;
use vortex_array::dtype::PType;
use vortex_array::dtype::extension::ExtDType;
use vortex_array::dtype::extension::ExtId;
use vortex_array::dtype::extension::ExtVTable;
use vortex_array::dtype::i256;
use vortex_array::optimizer::ArrayOptimizer;
use vortex_array::scalar::Scalar;
use vortex_array::scalar::ScalarValue;
use vortex_array::scalar_fn::ScalarFnVTable;
use vortex_array::scalar_fn::TypedScalarFnInstance;
use vortex_array::validity::Validity;
use vortex_buffer::BitBuffer;
use vortex_buffer::buffer;
use vortex_error::VortexResult;
use vortex_error::vortex_bail;
use vortex_expr::ArrayExprExt;
use vortex_expr::lit;
use vortex_expr::root;
use vortex_mask::Mask;
use vortex_session::VortexSession;
use super::PreparedSet;
use crate::expr::list_contains;
use crate::list_contains::ListContains;
use crate::list_contains::ListContainsOptions;
use crate::list_contains::PreparedSetData;
static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
let session = VortexSession::empty();
vortex_array::initialize(&session);
crate::initialize(&session);
session
});
fn prepare(list: &Scalar) -> VortexResult<PreparedSetData> {
PreparedSetData::try_new(list.clone())
}
fn prepare_array(list: &Scalar, len: usize) -> VortexResult<ArrayRef> {
PreparedSet::try_new_array(list.clone(), len)
}
fn list_scalar(elements: &ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult<Scalar> {
let values = (0..elements.len())
.map(|idx| elements.execute_scalar(idx, ctx))
.collect::<VortexResult<Vec<_>>>()?;
Ok(Scalar::list(
elements.dtype().clone(),
values,
Nullability::NonNullable,
))
}
fn nested_needles() -> ArrayRef {
let mut ctx = SESSION.create_execution_ctx();
ListArray::try_new(
PrimitiveArray::from_option_iter([Some(1i32), None, Some(2), None, Some(9)]).into_array(),
buffer![0u32, 2, 2, 4, 5].into_array(),
Validity::from(BitBuffer::from_iter([true, false, true, true])),
&mut ctx,
)
.unwrap()
.into_array()
}
fn map_needles() -> ArrayRef {
let ctx = SESSION.create_execution_ctx();
let dtype = DType::map(
DType::Primitive(PType::I32, Nullability::NonNullable),
DType::Utf8(Nullability::Nullable),
false,
Nullability::Nullable,
)
.unwrap();
let mut builder = builder_with_capacity_in(&dtype, 4, ctx.allocator());
for key in [Some(1i32), None, Some(2), Some(9)] {
let scalar = match key {
Some(key) => Scalar::map(
dtype.clone(),
[(key.into(), Scalar::null(DType::Utf8(Nullability::Nullable)))],
),
None => Scalar::null(dtype.clone()),
};
builder.append_scalar(&scalar).unwrap();
}
builder.finish()
}
fn struct_needles() -> ArrayRef {
StructArray::from_fields(&[("list", nested_needles())])
.unwrap()
.into_array()
}
#[rstest]
#[case::list(nested_needles())]
#[case::map(map_needles())]
#[case::struct_of_lists(struct_needles())]
#[case::fixed_size_list(FixedSizeListArray::new(
PrimitiveArray::from_option_iter([
Some(1i32), None, Some(2), None, Some(9), None, Some(8), None,
]).into_array(),
2, Validity::NonNullable, 4,
).into_array())]
fn test_row_set_returns_membership_bits(
#[case] needles: ArrayRef,
#[values(false, true)] sql_null_semantics: bool,
) -> VortexResult<()> {
let mut ctx = SESSION.create_execution_ctx();
let dtype = needles.dtype().as_nullable();
let members = [2, 0, 2]
.map(|idx| needles.execute_scalar(idx, &mut ctx)?.cast(&dtype))
.into_iter()
.collect::<VortexResult<Vec<_>>>()?;
let mut elements = members.clone();
elements.push(Scalar::null(dtype.clone()));
let list = Scalar::list(dtype, elements, Nullability::NonNullable);
let options = ListContainsOptions { sql_null_semantics };
let set = prepare(&list)?;
let result = set.contains(&needles, &options, &mut ctx)?;
assert!(result.is::<Bool>());
let expected = (0..needles.len())
.map(|idx| {
let value = needles.execute_scalar(idx, &mut ctx)?;
Ok(if value.is_null() {
None
} else if members.contains(&value) {
Some(true)
} else if sql_null_semantics {
None
} else {
Some(false)
})
})
.collect::<VortexResult<Vec<_>>>()?;
let nullability = needles.dtype().nullability() | Nullability::from(sql_null_semantics);
assert_eq!(result.dtype(), &DType::Bool(nullability));
let validity = match nullability {
Nullability::NonNullable => Validity::NonNullable,
Nullability::Nullable => Validity::from_iter(expected.iter().map(Option::is_some)),
};
let expected = BoolArray::new(
BitBuffer::from_iter(expected.into_iter().map(Option::unwrap_or_default)),
validity,
);
assert_arrays_eq!(result, expected, &mut ctx);
Ok(())
}
#[rstest]
fn test_decimal_bitmap_across_storage_widths(
#[values(2, 4, 9, 18, 38, 76)] precision: u8,
#[values(false, true)] sql_null_semantics: bool,
) -> VortexResult<()> {
let mut ctx = SESSION.create_execution_ctx();
let decimal = DecimalDType::new(precision, 1);
let dtype = DType::Decimal(decimal, Nullability::Nullable);
let mut elements: Vec<_> = [1i8, -2, 1]
.map(|value| Scalar::decimal(value.into(), decimal, Nullability::Nullable))
.into();
elements.push(Scalar::null(dtype.clone()));
let list = Scalar::list(dtype, elements, Nullability::NonNullable);
let needles =
DecimalArray::from_option_iter([Some(-2i8), Some(0), Some(1), None], decimal).into_array();
let options = ListContainsOptions { sql_null_semantics };
let set = prepare(&list)?;
let non_match = (!sql_null_semantics).then_some(false);
assert_arrays_eq!(
set.contains(&needles, &options, &mut ctx)?,
BoolArray::from_iter([Some(true), non_match, Some(true), None]),
&mut ctx
);
Ok(())
}
#[rstest]
#[case::dense_i128(38, i256::from_i128(1i128 << 100), true)]
#[case::sparse_i128(38, i256::from_i128(1i128 << 100), false)]
#[case::dense_i256(76, i256::from_parts(0, 1i128 << 72), true)]
#[case::sparse_i256(76, i256::from_parts(0, 1i128 << 72), false)]
fn test_decimal_wide_values(
#[case] precision: u8,
#[case] base: i256,
#[case] dense: bool,
) -> VortexResult<()> {
let mut ctx = SESSION.create_execution_ctx();
let decimal = DecimalDType::new(precision, 2);
let second = if dense { base + i256::ONE } else { -base };
let list = Scalar::list(
DType::Decimal(decimal, Nullability::NonNullable),
[second, base, second]
.map(|v| Scalar::decimal(v.into(), decimal, Nullability::NonNullable))
.into(),
Nullability::NonNullable,
);
let needles = DecimalArray::from_option_iter::<i256, _>(
[
Some(base),
Some(second),
Some(base - i256::ONE),
Some(i256::ZERO),
Some(base + i256::from_i128(1i128 << 64)),
None,
],
decimal,
)
.into_array();
let set = prepare(&list)?;
assert_arrays_eq!(
set.contains(&needles, &ListContainsOptions::default(), &mut ctx)?,
BoolArray::from_iter([
Some(true),
Some(true),
Some(false),
Some(false),
Some(false),
None,
]),
&mut ctx
);
Ok(())
}
#[rstest]
#[case::bitmap(
PrimitiveArray::from_option_iter([Some(5i64), Some(-3), Some(5)]).into_array(),
PrimitiveArray::from_option_iter([Some(-3i64), Some(4), Some(i64::MIN), None]).into_array(),
[Some(true), Some(false), Some(false), None],
)]
#[case::unsigned_in_signed_order(
PrimitiveArray::from_option_iter([Some(u64::MAX), Some(0), Some(1 << 40)]).into_array(),
PrimitiveArray::from_option_iter([Some(1u64 << 40), Some(1), Some(u64::MAX), Some(0)])
.into_array(),
[Some(true), Some(false), Some(true), Some(true)],
)]
#[case::float_bits(
PrimitiveArray::from_option_iter([Some(0.0f64), Some(f64::NAN)]).into_array(),
PrimitiveArray::from_option_iter([Some(-0.0f64), Some(0.0), Some(f64::NAN), Some(1.5)])
.into_array(),
[Some(false), Some(true), Some(true), Some(false)],
)]
fn test_primitive_integers(
#[case] elements: ArrayRef,
#[case] needles: ArrayRef,
#[case] expected: [Option<bool>; 4],
) -> VortexResult<()> {
let mut ctx = SESSION.create_execution_ctx();
let set = PreparedSetData::try_new(list_scalar(&elements, &mut ctx)?)?;
assert_arrays_eq!(
set.contains(&needles, &ListContainsOptions::default(), &mut ctx)?,
BoolArray::from_iter(expected),
&mut ctx
);
Ok(())
}
#[test]
fn test_compressed_needles_in_batches() -> VortexResult<()> {
let mut ctx = SESSION.create_execution_ctx();
let set = PreparedSetData::try_new(list_scalar(
&buffer![3i64, 9000, 20_001].into_array(),
&mut ctx,
)?)?;
let values = |range: std::ops::Range<i64>| {
PrimitiveArray::from_option_iter(range.map(|v| (v % 7 != 0).then_some(v))).into_array()
};
let needles = ChunkedArray::try_new(
vec![values(0..12_000), values(12_000..25_000)],
DType::Primitive(PType::I64, Nullability::Nullable),
)?
.into_array();
let expected = BoolArray::from_iter(
(0..25_000i64).map(|v| (v % 7 != 0).then_some(matches!(v, 3 | 9000 | 20_001))),
);
assert_arrays_eq!(
set.contains(&needles, &ListContainsOptions::default(), &mut ctx)?,
expected,
&mut ctx
);
Ok(())
}
fn set_with_null() -> Scalar {
let element = DType::Primitive(PType::I32, Nullability::Nullable);
Scalar::list(
element.clone(),
vec![
Scalar::primitive(2i32, Nullability::Nullable),
Scalar::null(element),
],
Nullability::NonNullable,
)
}
#[test]
fn test_prepared_set_rows_are_the_constant_list() -> VortexResult<()> {
let mut ctx = SESSION.create_execution_ctx();
let set = prepare_array(&set_with_null(), 4)?;
assert_arrays_eq!(set, ConstantArray::new(set_with_null(), 4), &mut ctx);
let prepared = PreparedSet::set_of(&set).expect("prepared set");
let sliced = set.slice(1..3)?.optimize_ctx(&SESSION)?;
assert_eq!(sliced.len(), 2);
assert!(PreparedSet::set_of(&sliced).is_some_and(|sliced| sliced.shares_set_with(prepared)));
let filtered = set
.filter(Mask::from_iter([true, false, true, true]))?
.optimize_ctx(&SESSION)?;
assert_eq!(filtered.len(), 3);
assert!(
PreparedSet::set_of(&filtered).is_some_and(|filtered| filtered.shares_set_with(prepared))
);
Ok(())
}
#[rstest]
#[case::default(ListContainsOptions::default(), [Some(false), Some(true), None, Some(false)])]
#[case::sql(
ListContainsOptions { sql_null_semantics: true },
[None, Some(true), None, None]
)]
fn test_list_contains_looks_up_in_a_prepared_set_list(
#[case] options: ListContainsOptions,
#[case] expected: [Option<bool>; 4],
) -> VortexResult<()> {
let mut ctx = SESSION.create_execution_ctx();
let set = prepare_array(&set_with_null(), 4)?;
let needles =
PrimitiveArray::from_option_iter([Some(1i32), Some(2), None, Some(3)]).into_array();
let result = ListContains::try_new_opts(set, needles, options)?.into_array();
assert_arrays_eq!(result, BoolArray::from_iter(expected), &mut ctx);
Ok(())
}
#[rstest]
#[case::default(ListContainsOptions::default(), Some(false))]
#[case::sql(ListContainsOptions { sql_null_semantics: true }, None)]
fn test_constant_needle_gives_a_constant(
#[case] options: ListContainsOptions,
#[case] expected: Option<bool>,
) -> VortexResult<()> {
let mut ctx = SESSION.create_execution_ctx();
let set = prepare_array(&set_with_null(), 4)?;
let needle = ConstantArray::new(Scalar::primitive(3i32, Nullability::Nullable), 4).into_array();
let result = ListContains::try_new_opts(set, needle, options)?
.into_array()
.execute::<ArrayRef>(&mut ctx)?;
let expected = match expected {
Some(value) => Scalar::bool(value, Nullability::Nullable),
None => Scalar::null(DType::Bool(Nullability::Nullable)),
};
assert_eq!(result.as_constant(), Some(&expected));
Ok(())
}
#[test]
fn test_constant_row_needle_looks_up_one_row() -> VortexResult<()> {
let mut ctx = SESSION.create_execution_ctx();
let needles = nested_needles();
let dtype = needles.dtype().as_nullable();
let member = needles.execute_scalar(2, &mut ctx)?.cast(&dtype)?;
let list = Scalar::list(dtype, vec![member.clone()], Nullability::NonNullable);
let set = prepare_array(&list, 4)?;
let needle = ConstantArray::new(member, 4).into_array();
let result = ListContains::try_new_opts(set, needle, ListContainsOptions::default())?
.into_array()
.execute::<ArrayRef>(&mut ctx)?;
assert_eq!(
result.as_constant(),
Some(&Scalar::bool(true, Nullability::Nullable))
);
Ok(())
}
#[rstest]
#[case::default(ListContainsOptions::default(), [Some(true), Some(false), None])]
#[case::sql(ListContainsOptions { sql_null_semantics: true }, [Some(true), None, None])]
fn test_result_from_bits_applies_null_semantics(
#[case] options: ListContainsOptions,
#[case] expected: [Option<bool>; 3],
) -> VortexResult<()> {
let mut ctx = SESSION.create_execution_ctx();
let set = prepare(&set_with_null())?;
let needle_dtype = DType::Primitive(PType::I32, Nullability::Nullable);
let bits = BitBuffer::from_iter([true, false, true]);
let validity = Validity::from_iter([true, true, false]);
let result = set.result_from_bits(bits, validity, &needle_dtype, &options)?;
assert_arrays_eq!(result, BoolArray::from_iter(expected), &mut ctx);
Ok(())
}
#[test]
fn test_result_from_bits_rejects_mismatched_needles() -> VortexResult<()> {
let set = prepare(&set_with_null())?;
let options = ListContainsOptions::default();
let bits = BitBuffer::from_iter([true, false]);
let long_validity = Validity::from_iter([true, false, true]);
let needle_dtype = DType::Primitive(PType::I32, Nullability::Nullable);
assert!(
set.result_from_bits(bits.clone(), long_validity, &needle_dtype, &options)
.is_err()
);
let wrong_dtype = DType::Primitive(PType::I64, Nullability::Nullable);
assert!(
set.result_from_bits(bits, Validity::AllValid, &wrong_dtype, &options)
.is_err()
);
Ok(())
}
#[test]
fn test_bytes_set_short_and_long_views() -> VortexResult<()> {
let mut ctx = SESSION.create_execution_ctx();
let elements = VarBinViewArray::from_iter_nullable_str([
Some("ab"),
Some(""),
Some("a long string with suffix A"),
Some("another long string"),
None,
Some("ab"),
])
.into_array();
let set = PreparedSetData::try_new(list_scalar(&elements, &mut ctx)?)?;
let needles = VarBinViewArray::from_iter_nullable_str([
Some("ab"),
Some("abc"),
Some(""),
Some("a long string with suffix B"),
Some("another long string"),
Some("a string never in the set"),
None,
])
.into_array();
assert_arrays_eq!(
set.contains(&needles, &ListContainsOptions::default(), &mut ctx)?,
BoolArray::from_iter([
Some(true),
Some(false),
Some(true),
Some(false),
Some(true),
Some(false),
None,
]),
&mut ctx
);
Ok(())
}
fn chunked_needles() -> VortexResult<ArrayRef> {
Ok(ChunkedArray::try_new(
vec![
PrimitiveArray::from_option_iter([Some(1i32), Some(2)]).into_array(),
PrimitiveArray::from_option_iter::<i32, _>([]).into_array(),
PrimitiveArray::from_option_iter([None, Some(3), Some(2)]).into_array(),
],
DType::Primitive(PType::I32, Nullability::Nullable),
)?
.into_array())
}
fn list_set(node: &ArrayRef) -> PreparedSetData {
PreparedSet::set_of(node.as_::<ScalarFn>().get_child(0))
.expect("the list of the node is a prepared set")
.clone()
}
fn assert_chunks_share_one_set(array: &ArrayRef) {
let chunked = array.as_::<Chunked>();
let sets: Vec<_> = chunked
.iter_chunks()
.filter(|chunk| !chunk.is_empty())
.map(list_set)
.collect();
assert!(sets.len() > 1);
assert!(sets.iter().all(|set| set.shares_set_with(&sets[0])));
}
#[rstest]
#[case::default(
ListContainsOptions::default(),
[Some(false), Some(true), None, Some(false), Some(true)],
)]
#[case::sql(
ListContainsOptions { sql_null_semantics: true },
[None, Some(true), None, None, Some(true)],
)]
fn test_constant_list_over_chunked_needles(
#[case] options: ListContainsOptions,
#[case] expected: [Option<bool>; 5],
) -> VortexResult<()> {
let mut ctx = SESSION.create_execution_ctx();
let needles = chunked_needles()?;
let list = ConstantArray::new(set_with_null(), needles.len()).into_array();
let array = ListContains::try_new_opts(list, needles, options)?
.into_array()
.optimize_ctx(&SESSION)?;
assert_chunks_share_one_set(&array);
assert_arrays_eq!(array, BoolArray::from_iter(expected), &mut ctx);
Ok(())
}
#[test]
fn test_optimized_expression_over_chunked_needles() -> VortexResult<()> {
let mut ctx = SESSION.create_execution_ctx();
let needles = chunked_needles()?;
let expr = list_contains(lit(set_with_null()), root())
.bind(needles.dtype())?
.optimize()?;
let array = needles.apply_bound(&expr)?.optimize_ctx(&SESSION)?;
assert_chunks_share_one_set(&array);
assert_arrays_eq!(
array,
BoolArray::from_iter([Some(false), Some(true), None, Some(false), Some(true)]),
&mut ctx
);
Ok(())
}
#[test]
fn test_scalar_fn_without_children_requires_explicit_len() -> VortexResult<()> {
let list = Scalar::list(
DType::Primitive(PType::I32, Nullability::NonNullable),
vec![Scalar::from(1i32)],
Nullability::NonNullable,
);
let scalar_fn =
TypedScalarFnInstance::new(PreparedSet, PreparedSetData::try_new(list.clone())?).erased();
let Err(err) = ScalarFnArray::try_new(scalar_fn.clone(), vec![]) else {
panic!("ScalarFnArray::try_new should reject zero children");
};
assert!(
err.to_string()
.contains("ScalarFnArray length cannot be inferred without children")
);
let scalar_fn_array = ScalarFnArray::try_new_with_len(scalar_fn, vec![], 3)?;
assert_eq!(scalar_fn_array.len(), 3);
assert_eq!(scalar_fn_array.child_count(), 0);
assert_arrays_eq!(
scalar_fn_array,
ConstantArray::new(list, 3),
&mut SESSION.create_execution_ctx()
);
Ok(())
}
#[test]
fn test_filter_pushdown_without_children() -> VortexResult<()> {
let list = Scalar::list(
DType::Primitive(PType::I32, Nullability::NonNullable),
vec![Scalar::from(7i32)],
Nullability::NonNullable,
);
let array = PreparedSet::try_new_array(list.clone(), 3)?;
let result = FilterArray::try_new(array, Mask::from_iter([true, false, true]))?
.into_array()
.optimize_ctx(&SESSION)?;
assert_eq!(result.as_::<ScalarFn>().nchildren(), 0);
assert_eq!(result.len(), 2);
assert_arrays_eq!(
result,
ConstantArray::new(list, 2),
&mut SESSION.create_execution_ctx()
);
Ok(())
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
struct FailingMetadata;
impl ExtVTable for FailingMetadata {
type Metadata = usize;
type StoredMetadata = Self::Metadata;
type NativeValue<'a> = &'a str;
#[expect(clippy::disallowed_methods, reason = "test-only id")]
fn id(&self) -> ExtId {
ExtId::new("test.failing_metadata")
}
fn serialize_metadata(&self, _metadata: &Self::Metadata) -> VortexResult<Vec<u8>> {
vortex_bail!("metadata serializer failed")
}
fn deserialize_metadata(&self, _data: &[u8]) -> VortexResult<Self::StoredMetadata> {
Ok(0)
}
fn metadata_from_storage(
&self,
stored_metadata: Self::StoredMetadata,
_storage_dtype: &DType,
) -> VortexResult<Self::Metadata> {
Ok(stored_metadata)
}
fn storage_dtype(_metadata: &Self::Metadata) -> DType {
DType::Primitive(PType::I32, Nullability::NonNullable)
}
fn unpack_native<'a>(
_ext_dtype: &'a ExtDType<Self>,
_storage_value: &'a ScalarValue,
) -> VortexResult<Self::NativeValue<'a>> {
Ok("")
}
}
#[test]
fn serialize_propagates_extension_metadata_error() -> VortexResult<()> {
let scalar =
Scalar::extension::<FailingMetadata>(0, Scalar::primitive(1i32, Nullability::NonNullable));
let list = Scalar::list(
scalar.dtype().clone(),
vec![scalar],
Nullability::NonNullable,
);
let set = PreparedSetData::try_new(list)?;
let err = PreparedSet
.serialize(&set)
.expect_err("serializing an extension whose metadata serializer fails must fail");
assert!(
err.to_string().contains("metadata serializer failed"),
"{err}"
);
Ok(())
}
#[rstest]
#[case::default(null_code_needles(), ListContainsOptions::default(), set_with_null(), vec![Some(true), Some(false), None, Some(true)])]
#[case::sql(null_code_needles(), ListContainsOptions { sql_null_semantics: true }, set_with_null(), vec![Some(true), None, None, Some(true)])]
#[case::empty(null_code_needles(), ListContainsOptions::default(), empty_i32_set(), vec![Some(false); 4])]
#[case::empty_sql(null_code_needles(), ListContainsOptions { sql_null_semantics: true }, empty_i32_set(), vec![Some(false), Some(false), None, Some(false)])]
#[case::null_value(null_value_needles(), ListContainsOptions::default(), set_with_null(), vec![Some(true), Some(false), Some(true), None, Some(false)])]
fn test_dictionary_needles(
#[case] needles: VortexResult<ArrayRef>,
#[case] options: ListContainsOptions,
#[case] set: Scalar,
#[case] expected: Vec<Option<bool>>,
) -> VortexResult<()> {
let mut ctx = SESSION.create_execution_ctx();
let needles = needles?;
let list = ConstantArray::new(set, needles.len()).into_array();
let array = ListContains::try_new_opts(list, needles, options)?
.into_array()
.optimize_ctx(&SESSION)?;
assert!(!array.is::<ScalarFn>());
if let Some(dict) = array.as_opt::<Dict>() {
let values = dict.values().clone();
assert!(PreparedSet::set_of(values.as_::<ScalarFn>().get_child(0)).is_some());
}
assert_arrays_eq!(array, BoolArray::from_iter(expected), &mut ctx);
Ok(())
}
fn null_code_needles() -> VortexResult<ArrayRef> {
Ok(DictArray::try_new(
PrimitiveArray::from_option_iter([Some(0u8), Some(1), None, Some(0)]).into_array(),
buffer![2i32, 3].into_array(),
)?
.into_array())
}
fn null_value_needles() -> VortexResult<ArrayRef> {
Ok(DictArray::try_new(
buffer![0u8, 1, 0, 2, 1].into_array(),
PrimitiveArray::from_option_iter([Some(2i32), Some(3), None]).into_array(),
)?
.into_array())
}
fn empty_i32_set() -> Scalar {
Scalar::list(
DType::Primitive(PType::I32, Nullability::Nullable),
vec![],
Nullability::NonNullable,
)
}