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

vortex-data / vortex / 16729059657

04 Aug 2025 04:45PM UTC coverage: 83.417% (-0.3%) from 83.688%
16729059657

Pull #4109

github

web-flow
Merge 824cda705 into 7a35bb974
Pull Request #4109: Revert "feat: implement Cast Kernel everywhere"

13 of 13 new or added lines in 1 file covered. (100.0%)

45 existing lines in 12 files now uncovered.

46430 of 55660 relevant lines covered (83.42%)

449843.23 hits per line

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

95.0
/vortex-array/src/arrays/bool/compute/cast.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
use vortex_dtype::DType;
5
use vortex_error::VortexResult;
6

7
use crate::array::ArrayRef;
8
use crate::arrays::{BoolArray, BoolVTable};
9
use crate::compute::{CastKernel, CastKernelAdapter};
10
use crate::register_kernel;
11
use crate::vtable::ValidityHelper;
12

13
impl CastKernel for BoolVTable {
14
    fn cast(&self, array: &BoolArray, dtype: &DType) -> VortexResult<Option<ArrayRef>> {
54✔
15
        if !matches!(dtype, DType::Bool(_)) {
54✔
UNCOV
16
            return Ok(None);
×
17
        }
54✔
18

19
        let new_nullability = dtype.nullability();
54✔
20
        let new_validity = array.validity().clone().cast_nullability(new_nullability)?;
54✔
21
        Ok(Some(
53✔
22
            BoolArray::new(array.boolean_buffer().clone(), new_validity).to_array(),
53✔
23
        ))
53✔
24
    }
54✔
25
}
26

27
register_kernel!(CastKernelAdapter(BoolVTable).lift());
28

29
#[cfg(test)]
30
mod tests {
31
    use vortex_dtype::{DType, Nullability};
32

33
    use crate::arrays::BoolArray;
34
    use crate::compute::cast;
35

36
    #[test]
37
    fn try_cast_bool_success() {
1✔
38
        let bool = BoolArray::from_iter(vec![Some(true), Some(false), Some(true)]);
1✔
39

40
        let res = cast(bool.as_ref(), &DType::Bool(Nullability::NonNullable));
1✔
41
        assert!(res.is_ok());
1✔
42
        assert_eq!(res.unwrap().dtype(), &DType::Bool(Nullability::NonNullable));
1✔
43
    }
1✔
44

45
    #[test]
46
    #[should_panic]
47
    fn try_cast_bool_fail() {
1✔
48
        let bool = BoolArray::from_iter(vec![Some(true), Some(false), None]);
1✔
49
        cast(bool.as_ref(), &DType::Bool(Nullability::NonNullable)).unwrap();
1✔
50
    }
1✔
51
}
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