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

vortex-data / vortex / 17073077835

19 Aug 2025 02:40PM UTC coverage: 24.083%. First build
17073077835

Pull #4177

github

web-flow
Merge b42e5758f into 431a8f2b5
Pull Request #4177: feat: ArrayOperations infallible, eager validation + new_unchecked

197 of 1455 new or added lines in 154 files covered. (13.54%)

8646 of 35901 relevant lines covered (24.08%)

142.28 hits per line

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

26.67
/vortex-expr/src/transform/remove_select.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
use vortex_error::{VortexResult, vortex_err};
5

6
use crate::traversal::{NodeExt, Transformed};
7
use crate::{DType, ExprRef, SelectVTable, get_item, pack};
8

9
/// Replaces [crate::SelectExpr] with combination of [crate::GetItem] and [crate::Pack] expressions.
10
pub(crate) fn remove_select(e: ExprRef, ctx: &DType) -> VortexResult<ExprRef> {
14✔
11
    e.transform_up(|node| remove_select_transformer(node, ctx))
48✔
12
        .map(|e| e.into_inner())
14✔
13
}
14✔
14

15
fn remove_select_transformer(node: ExprRef, ctx: &DType) -> VortexResult<Transformed<ExprRef>> {
48✔
16
    match node.as_opt::<SelectVTable>() {
48✔
17
        None => Ok(Transformed::no(node)),
48✔
18
        Some(select) => {
×
19
            let child = select.child();
×
20
            let child_dtype = child.return_dtype(ctx)?;
×
21
            let child_nullability = child_dtype.nullability();
×
22

NEW
23
            let child_dtype = child_dtype.as_struct_opt().ok_or_else(|| {
×
24
                vortex_err!(
×
25
                    "Select child must return a struct dtype, however it was a {}",
×
26
                    child_dtype
27
                )
28
            })?;
×
29

30
            let expr = pack(
×
31
                select
×
32
                    .fields()
×
33
                    .as_include_names(child_dtype.names())
×
34
                    .map_err(|e| {
×
35
                        e.with_context(format!(
×
36
                            "Select fields {:?} must be a subset of child fields {:?}",
×
37
                            select.fields(),
×
38
                            child_dtype.names()
×
39
                        ))
40
                    })?
×
41
                    .iter()
×
42
                    .map(|name| (name.clone(), get_item(name.clone(), child.clone()))),
×
43
                child_nullability,
×
44
            );
45

46
            Ok(Transformed::yes(expr))
×
47
        }
48
    }
49
}
48✔
50

51
#[cfg(test)]
52
mod tests {
53

54
    use vortex_dtype::Nullability::Nullable;
55
    use vortex_dtype::PType::I32;
56
    use vortex_dtype::{DType, StructFields};
57

58
    use crate::transform::remove_select::remove_select;
59
    use crate::{PackVTable, root, select};
60

61
    #[test]
62
    fn test_remove_select() {
63
        let dtype = DType::Struct(
64
            StructFields::new(["a", "b"].into(), vec![I32.into(), I32.into()]),
65
            Nullable,
66
        );
67
        let e = select(["a", "b"], root());
68
        let e = remove_select(e, &dtype).unwrap();
69

70
        assert!(e.is::<PackVTable>());
71
        assert!(e.return_dtype(&dtype).unwrap().is_nullable());
72
    }
73
}
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