vortex_functions/zip/
null.rs1use vortex_array::ArrayRef;
5use vortex_array::ArrayView;
6use vortex_array::arrays::Null;
7use vortex_error::VortexResult;
8
9use crate::zip::ZipReduce;
10
11impl ZipReduce for Null {
12 fn zip(
13 array: ArrayView<'_, Null>,
14 _if_false: &ArrayRef,
15 _mask: &ArrayRef,
16 ) -> VortexResult<Option<ArrayRef>> {
17 Ok(Some(array.array().clone()))
19 }
20}
21
22#[cfg(test)]
23mod tests {
24 use std::sync::LazyLock;
25
26 use vortex_array::ArrayRef;
27 use vortex_array::IntoArray;
28 use vortex_array::VortexSessionExecute;
29 use vortex_array::arrays::Null;
30 use vortex_array::arrays::NullArray;
31 use vortex_array::assert_arrays_eq;
32 use vortex_error::VortexResult;
33 use vortex_mask::Mask;
34 use vortex_session::VortexSession;
35
36 use crate::builtins::ArrayFunctions;
37
38 static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
39 let session = VortexSession::empty();
40 vortex_array::initialize(&session);
41 crate::initialize(&session);
42 session
43 });
44
45 #[test]
46 fn zip_nulls() -> VortexResult<()> {
47 let mut ctx = SESSION.create_execution_ctx();
48 let result = Mask::from_iter([true, false, true, false, false])
49 .into_array()
50 .zip(
51 NullArray::new(5).into_array(),
52 NullArray::new(5).into_array(),
53 )?
54 .execute::<ArrayRef>(&mut ctx)?;
55
56 assert!(result.is::<Null>());
57 assert_arrays_eq!(result, NullArray::new(5), &mut ctx);
58 Ok(())
59 }
60}