• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vortex-data / vortex / 16935267080

13 Aug 2025 11:00AM UTC coverage: 24.312% (-63.3%) from 87.658%
16935267080

Pull #4226

github

web-flow
Merge 81b48c7fb into baa6ea202
Pull Request #4226: Support converting TimestampTZ to and from duckdb

0 of 2 new or added lines in 1 file covered. (0.0%)

20666 existing lines in 469 files now uncovered.

8726 of 35892 relevant lines covered (24.31%)

147.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/vortex-array/src/arrays/null/compute/mod.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
mod cast;
5

6
use vortex_dtype::match_each_integer_ptype;
7
use vortex_error::{VortexResult, vortex_bail};
8
use vortex_mask::Mask;
9

10
use crate::arrays::NullVTable;
11
use crate::arrays::null::NullArray;
12
use crate::compute::{
13
    FilterKernel, FilterKernelAdapter, MaskKernel, MaskKernelAdapter, MinMaxKernel,
14
    MinMaxKernelAdapter, MinMaxResult, TakeKernel, TakeKernelAdapter,
15
};
16
use crate::{Array, ArrayRef, IntoArray, ToCanonical, register_kernel};
17

18
impl FilterKernel for NullVTable {
UNCOV
19
    fn filter(&self, _array: &Self::Array, mask: &Mask) -> VortexResult<ArrayRef> {
×
UNCOV
20
        Ok(NullArray::new(mask.true_count()).into_array())
×
UNCOV
21
    }
×
22
}
23

24
register_kernel!(FilterKernelAdapter(NullVTable).lift());
25

26
impl MaskKernel for NullVTable {
UNCOV
27
    fn mask(&self, array: &NullArray, _mask: &Mask) -> VortexResult<ArrayRef> {
×
UNCOV
28
        Ok(array.to_array())
×
UNCOV
29
    }
×
30
}
31

32
register_kernel!(MaskKernelAdapter(NullVTable).lift());
33

34
impl TakeKernel for NullVTable {
35
    #[allow(clippy::cast_possible_truncation)]
UNCOV
36
    fn take(&self, array: &NullArray, indices: &dyn Array) -> VortexResult<ArrayRef> {
×
UNCOV
37
        let indices = indices.to_primitive()?;
×
38

39
        // Enforce all indices are valid
UNCOV
40
        match_each_integer_ptype!(indices.ptype(), |T| {
×
41
            for index in indices.as_slice::<T>() {
×
42
                if (*index as usize) >= array.len() {
×
43
                    vortex_bail!(OutOfBounds: *index as usize, 0, array.len());
×
44
                }
×
45
            }
46
        });
47

UNCOV
48
        Ok(NullArray::new(indices.len()).into_array())
×
UNCOV
49
    }
×
50
}
51

52
register_kernel!(TakeKernelAdapter(NullVTable).lift());
53

54
impl MinMaxKernel for NullVTable {
55
    fn min_max(&self, _array: &NullArray) -> VortexResult<Option<MinMaxResult>> {
×
56
        Ok(None)
×
57
    }
×
58
}
59

60
register_kernel!(MinMaxKernelAdapter(NullVTable).lift());
61

62
#[cfg(test)]
63
mod test {
64
    use vortex_buffer::buffer;
65
    use vortex_dtype::DType;
66
    use vortex_mask::Mask;
67

68
    use crate::arrays::null::NullArray;
69
    use crate::compute::conformance::filter::test_filter_conformance;
70
    use crate::compute::conformance::mask::test_mask_conformance;
71
    use crate::compute::conformance::take::test_take_conformance;
72
    use crate::compute::take;
73
    use crate::{IntoArray, ToCanonical};
74

75
    #[test]
76
    fn test_slice_nulls() {
77
        let nulls = NullArray::new(10);
78
        let sliced = nulls.slice(0, 4).unwrap().to_null().unwrap();
79

80
        assert_eq!(sliced.len(), 4);
81
        assert!(matches!(sliced.validity_mask().unwrap(), Mask::AllFalse(4)));
82
    }
83

84
    #[test]
85
    fn test_take_nulls() {
86
        let nulls = NullArray::new(10);
87
        let taken = take(nulls.as_ref(), &buffer![0u64, 2, 4, 6, 8].into_array())
88
            .unwrap()
89
            .to_null()
90
            .unwrap();
91

92
        assert_eq!(taken.len(), 5);
93
        assert!(matches!(taken.validity_mask().unwrap(), Mask::AllFalse(5)));
94
    }
95

96
    #[test]
97
    fn test_scalar_at_nulls() {
98
        let nulls = NullArray::new(10);
99

100
        let scalar = nulls.scalar_at(0).unwrap();
101
        assert!(scalar.is_null());
102
        assert_eq!(scalar.dtype().clone(), DType::Null);
103
    }
104

105
    #[test]
106
    fn test_filter_null_array() {
107
        test_filter_conformance(NullArray::new(5).as_ref());
108
        test_filter_conformance(NullArray::new(1).as_ref());
109
        test_filter_conformance(NullArray::new(10).as_ref());
110
    }
111

112
    #[test]
113
    fn test_mask_null_array() {
114
        test_mask_conformance(NullArray::new(5).as_ref());
115
    }
116

117
    #[test]
118
    fn test_take_null_array_conformance() {
119
        test_take_conformance(NullArray::new(5).as_ref());
120
        test_take_conformance(NullArray::new(1).as_ref());
121
        test_take_conformance(NullArray::new(10).as_ref());
122
    }
123
}
124

125
#[cfg(test)]
126
mod tests {
127
    use rstest::rstest;
128

129
    use crate::arrays::NullArray;
130
    use crate::compute::conformance::consistency::test_array_consistency;
131

132
    #[rstest]
133
    // From test_all_consistency
134
    #[case::null_array_small(NullArray::new(5))]
135
    #[case::null_array_medium(NullArray::new(100))]
136
    // Additional test cases
137
    #[case::null_array_single(NullArray::new(1))]
138
    #[case::null_array_large(NullArray::new(1000))]
139
    #[case::null_array_empty(NullArray::new(0))]
140
    fn test_null_consistency(#[case] array: NullArray) {
141
        test_array_consistency(array.as_ref());
142
    }
143
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc