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

vortex-data / vortex / 16331938722

16 Jul 2025 10:49PM UTC coverage: 80.702% (-0.9%) from 81.557%
16331938722

push

github

web-flow
feat: build with stable rust (#3881)

120 of 173 new or added lines in 28 files covered. (69.36%)

174 existing lines in 102 files now uncovered.

41861 of 51871 relevant lines covered (80.7%)

157487.71 hits per line

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

79.49
/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::{MutNodeVisitor, Node, TransformResult};
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> {
15,315✔
11
    let mut transform = RemoveSelectTransform { ctx };
15,315✔
12
    e.transform(&mut transform).map(|e| e.into_inner())
15,315✔
13
}
15,315✔
14

15
struct RemoveSelectTransform<'a> {
16
    ctx: &'a DType,
17
}
18

19
impl MutNodeVisitor for RemoveSelectTransform<'_> {
20
    type NodeTy = ExprRef;
21

22
    fn visit_up(&mut self, node: ExprRef) -> VortexResult<TransformResult<Self::NodeTy>> {
65,554✔
23
        if let Some(select) = node.as_opt::<SelectVTable>() {
65,554✔
24
            let child = select.child();
996✔
25
            let child_dtype = child.return_dtype(self.ctx)?;
996✔
26
            let child_nullability = child_dtype.nullability();
996✔
27

28
            let child_dtype = child_dtype.as_struct().ok_or_else(|| {
996✔
29
                vortex_err!(
×
30
                    "Select child must return a struct dtype, however it was a {}",
×
31
                    child_dtype
32
                )
UNCOV
33
            })?;
×
34

35
            let expr = pack(
996✔
36
                select
996✔
37
                    .fields()
996✔
38
                    .as_include_names(child_dtype.names())
996✔
39
                    .map_err(|e| {
996✔
40
                        e.with_context(format!(
×
41
                            "Select fields {:?} must be a subset of child fields {:?}",
×
42
                            select.fields(),
×
43
                            child_dtype.names()
×
44
                        ))
UNCOV
45
                    })?
×
46
                    .iter()
996✔
47
                    .map(|name| (name.clone(), get_item(name.clone(), child.clone()))),
2,230✔
48
                child_nullability,
996✔
49
            );
50

51
            Ok(TransformResult::yes(expr))
996✔
52
        } else {
53
            Ok(TransformResult::no(node))
64,558✔
54
        }
55
    }
65,554✔
56
}
57

58
#[cfg(test)]
59
mod tests {
60

61
    use vortex_dtype::Nullability::Nullable;
62
    use vortex_dtype::PType::I32;
63
    use vortex_dtype::{DType, StructFields};
64

65
    use crate::transform::remove_select::remove_select;
66
    use crate::{PackVTable, root, select};
67

68
    #[test]
69
    fn test_remove_select() {
1✔
70
        let dtype = DType::Struct(
1✔
71
            StructFields::new(["a", "b"].into(), vec![I32.into(), I32.into()]),
1✔
72
            Nullable,
1✔
73
        );
1✔
74
        let e = select(["a", "b"], root());
1✔
75
        let e = remove_select(e, &dtype).unwrap();
1✔
76

77
        assert!(e.is::<PackVTable>());
1✔
78
        assert!(e.return_dtype(&dtype).unwrap().is_nullable());
1✔
79
    }
1✔
80
}
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

© 2025 Coveralls, Inc