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

vortex-data / vortex / 16201397870

10 Jul 2025 05:05PM UTC coverage: 81.145% (+0.06%) from 81.084%
16201397870

push

github

web-flow
Remove var expression (#3829)

Fixes #3671 

* Removes the Var expression, leaving instead a `root()` expression for
resolving the scope root.
* The expression scope can hold context variables, useful for passing in
auth tokens for example, but not variables that would impact the
return_dtype of the expression.
* ScopeDType has therefore been removed, because the dtype of the scope
_is_ just the dtype of the root array.
* Simplifies some transformation / partitioning logic where vars no
longer need to be considered.

Signed-off-by: Nicholas Gates <nick@nickgates.com>
Co-authored-by: Will Manning <will@spiraldb.com>

164 of 175 new or added lines in 32 files covered. (93.71%)

18 existing lines in 6 files now uncovered.

45273 of 55793 relevant lines covered (81.14%)

146273.04 hits per line

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

92.31
/vortex-expr/src/exprs/root.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
use std::fmt::Display;
5

6
use vortex_array::stats::Stat;
7
use vortex_array::{ArrayRef, DeserializeMetadata, EmptyMetadata};
8
use vortex_dtype::{DType, FieldPath};
9
use vortex_error::{VortexResult, vortex_bail};
10

11
use crate::{
12
    AnalysisExpr, ExprEncodingRef, ExprId, ExprRef, IntoExpr, Scope, StatsCatalog, VTable, vtable,
13
};
14

15
vtable!(Root);
16

17
/// An expression that returns the full scope of the expression evaluation.
18
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
19
pub struct RootExpr;
20

21
pub struct RootExprEncoding;
22

23
impl VTable for RootVTable {
24
    type Expr = RootExpr;
25
    type Encoding = RootExprEncoding;
26
    type Metadata = EmptyMetadata;
27

28
    fn id(_encoding: &Self::Encoding) -> ExprId {
126✔
29
        ExprId::new_ref("root")
126✔
30
    }
126✔
31

32
    fn encoding(_expr: &Self::Expr) -> ExprEncodingRef {
3✔
33
        ExprEncodingRef::new_ref(RootExprEncoding.as_ref())
3✔
34
    }
3✔
35

36
    fn metadata(_expr: &Self::Expr) -> Option<Self::Metadata> {
3✔
37
        Some(EmptyMetadata)
3✔
38
    }
3✔
39

40
    fn children(_expr: &Self::Expr) -> Vec<&ExprRef> {
313,233✔
41
        vec![]
313,233✔
42
    }
313,233✔
43

44
    fn with_children(expr: &Self::Expr, _children: Vec<ExprRef>) -> VortexResult<Self::Expr> {
1✔
45
        Ok(expr.clone())
1✔
46
    }
1✔
47

48
    fn build(
3✔
49
        _encoding: &Self::Encoding,
3✔
50
        _metadata: &<Self::Metadata as DeserializeMetadata>::Output,
3✔
51
        children: Vec<ExprRef>,
3✔
52
    ) -> VortexResult<Self::Expr> {
3✔
53
        if !children.is_empty() {
3✔
NEW
54
            vortex_bail!(
×
NEW
55
                "Root expression does not have children, got: {:?}",
×
NEW
56
                children
×
NEW
57
            );
×
58
        }
3✔
59
        Ok(RootExpr)
3✔
60
    }
3✔
61

62
    fn evaluate(_expr: &Self::Expr, scope: &Scope) -> VortexResult<ArrayRef> {
15,188✔
63
        Ok(scope.root().clone())
15,188✔
64
    }
15,188✔
65

66
    fn return_dtype(_expr: &Self::Expr, scope: &DType) -> VortexResult<DType> {
29,958✔
67
        Ok(scope.clone())
29,958✔
68
    }
29,958✔
69
}
70

71
impl Display for RootExpr {
72
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26✔
73
        write!(f, "$")
26✔
74
    }
26✔
75
}
76

77
impl AnalysisExpr for RootExpr {
78
    fn max(&self, catalog: &mut dyn StatsCatalog) -> Option<ExprRef> {
459✔
79
        catalog.stats_ref(&self.field_path()?, Stat::Max)
459✔
80
    }
459✔
81

82
    fn min(&self, catalog: &mut dyn StatsCatalog) -> Option<ExprRef> {
345✔
83
        catalog.stats_ref(&self.field_path()?, Stat::Min)
345✔
84
    }
345✔
85

86
    fn field_path(&self) -> Option<FieldPath> {
825✔
87
        Some(FieldPath::root())
825✔
88
    }
825✔
89
}
90

91
/// Return a global pointer to the identity token.
92
/// This is the name of the data found in a vortex array or file.
93
pub fn root() -> ExprRef {
30,164✔
94
    RootExpr.into_expr()
30,164✔
95
}
30,164✔
96

97
/// Return whether the expression is a root expression.
98
pub fn is_root(expr: &ExprRef) -> bool {
32,740✔
99
    expr.is::<RootVTable>()
32,740✔
100
}
32,740✔
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