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

vortex-data / vortex / 16473770414

23 Jul 2025 02:38PM UTC coverage: 80.988% (-0.07%) from 81.055%
16473770414

push

github

web-flow
chore[duckdb]: scan log info -> trace (#3989)

Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>

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

35 existing lines in 7 files now uncovered.

42052 of 51924 relevant lines covered (80.99%)

173623.22 hits per line

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

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

4
use std::fmt::{Debug, Display};
5

6
use vortex_array::compute::{BetweenOptions, StrictComparison, between as between_compute};
7
use vortex_array::{ArrayRef, DeserializeMetadata, ProstMetadata};
8
use vortex_dtype::DType;
9
use vortex_dtype::DType::Bool;
10
use vortex_error::{VortexResult, vortex_bail};
11
use vortex_proto::expr as pb;
12

13
use crate::{
14
    AnalysisExpr, BinaryExpr, ExprEncodingRef, ExprId, ExprRef, IntoExpr, Scope, VTable, vtable,
15
};
16

17
vtable!(Between);
18

19
#[allow(clippy::derived_hash_with_manual_eq)]
20
#[derive(Clone, Debug, Hash)]
21
pub struct BetweenExpr {
22
    arr: ExprRef,
23
    lower: ExprRef,
24
    upper: ExprRef,
25
    options: BetweenOptions,
26
}
27

28
impl PartialEq for BetweenExpr {
29
    fn eq(&self, other: &Self) -> bool {
1,099✔
30
        self.arr.eq(&other.arr)
1,099✔
31
            && self.lower.eq(&other.lower)
1,099✔
32
            && self.upper.eq(&other.upper)
1,099✔
33
            && self.options == other.options
1,099✔
34
    }
1,099✔
35
}
36

37
pub struct BetweenExprEncoding;
38

39
impl VTable for BetweenVTable {
40
    type Expr = BetweenExpr;
41
    type Encoding = BetweenExprEncoding;
42
    type Metadata = ProstMetadata<pb::BetweenOpts>;
43

44
    fn id(_encoding: &Self::Encoding) -> ExprId {
129✔
45
        ExprId::new_ref("between")
129✔
46
    }
129✔
47

48
    fn encoding(_expr: &Self::Expr) -> ExprEncodingRef {
1✔
49
        ExprEncodingRef::new_ref(BetweenExprEncoding.as_ref())
1✔
50
    }
1✔
51

52
    fn metadata(expr: &Self::Expr) -> Option<Self::Metadata> {
1✔
53
        Some(ProstMetadata(pb::BetweenOpts {
1✔
54
            lower_strict: expr.options.lower_strict == StrictComparison::Strict,
1✔
55
            upper_strict: expr.options.upper_strict == StrictComparison::Strict,
1✔
56
        }))
1✔
57
    }
1✔
58

59
    fn children(expr: &Self::Expr) -> Vec<&ExprRef> {
2,995✔
60
        vec![&expr.arr, &expr.lower, &expr.upper]
2,995✔
61
    }
2,995✔
62

63
    fn with_children(expr: &Self::Expr, children: Vec<ExprRef>) -> VortexResult<Self::Expr> {
129✔
64
        Ok(BetweenExpr::new(
129✔
65
            children[0].clone(),
129✔
66
            children[1].clone(),
129✔
67
            children[2].clone(),
129✔
68
            expr.options.clone(),
129✔
69
        ))
129✔
70
    }
129✔
71

72
    fn build(
1✔
73
        _encoding: &Self::Encoding,
1✔
74
        metadata: &<Self::Metadata as DeserializeMetadata>::Output,
1✔
75
        children: Vec<ExprRef>,
1✔
76
    ) -> VortexResult<Self::Expr> {
1✔
77
        Ok(BetweenExpr::new(
1✔
78
            children[0].clone(),
1✔
79
            children[1].clone(),
1✔
80
            children[2].clone(),
1✔
81
            BetweenOptions {
82
                lower_strict: if metadata.lower_strict {
1✔
83
                    StrictComparison::Strict
1✔
84
                } else {
85
                    StrictComparison::NonStrict
×
86
                },
87
                upper_strict: if metadata.upper_strict {
1✔
88
                    StrictComparison::Strict
1✔
89
                } else {
90
                    StrictComparison::NonStrict
×
91
                },
92
            },
93
        ))
94
    }
1✔
95

96
    fn evaluate(expr: &Self::Expr, scope: &Scope) -> VortexResult<ArrayRef> {
167✔
97
        let arr_val = expr.arr.unchecked_evaluate(scope)?;
167✔
98
        let lower_arr_val = expr.lower.unchecked_evaluate(scope)?;
167✔
99
        let upper_arr_val = expr.upper.unchecked_evaluate(scope)?;
167✔
100

101
        between_compute(&arr_val, &lower_arr_val, &upper_arr_val, &expr.options)
167✔
102
    }
167✔
103

104
    fn return_dtype(expr: &Self::Expr, scope: &DType) -> VortexResult<DType> {
253✔
105
        let arr_dt = expr.arr.return_dtype(scope)?;
253✔
106
        let lower_dt = expr.lower.return_dtype(scope)?;
253✔
107
        let upper_dt = expr.upper.return_dtype(scope)?;
253✔
108

109
        if !arr_dt.eq_ignore_nullability(&lower_dt) {
253✔
110
            vortex_bail!(
×
111
                "Array dtype {} does not match lower dtype {}",
×
112
                arr_dt,
113
                lower_dt
114
            );
115
        }
253✔
116
        if !arr_dt.eq_ignore_nullability(&upper_dt) {
253✔
117
            vortex_bail!(
×
118
                "Array dtype {} does not match upper dtype {}",
×
119
                arr_dt,
120
                upper_dt
121
            );
122
        }
253✔
123

124
        Ok(Bool(
253✔
125
            arr_dt.nullability() | lower_dt.nullability() | upper_dt.nullability(),
253✔
126
        ))
253✔
127
    }
253✔
128
}
129

130
impl BetweenExpr {
131
    pub fn new(arr: ExprRef, lower: ExprRef, upper: ExprRef, options: BetweenOptions) -> Self {
427✔
132
        Self {
427✔
133
            arr,
427✔
134
            lower,
427✔
135
            upper,
427✔
136
            options,
427✔
137
        }
427✔
138
    }
427✔
139

140
    pub fn new_expr(
43✔
141
        arr: ExprRef,
43✔
142
        lower: ExprRef,
43✔
143
        upper: ExprRef,
43✔
144
        options: BetweenOptions,
43✔
145
    ) -> ExprRef {
43✔
146
        Self::new(arr, lower, upper, options).into_expr()
43✔
147
    }
43✔
148

149
    pub fn to_binary_expr(&self) -> ExprRef {
×
150
        let lhs = BinaryExpr::new(
×
151
            self.lower.clone(),
×
152
            self.options.lower_strict.to_operator().into(),
×
153
            self.arr.clone(),
×
154
        );
155
        let rhs = BinaryExpr::new(
×
156
            self.arr.clone(),
×
157
            self.options.upper_strict.to_operator().into(),
×
158
            self.upper.clone(),
×
159
        );
160
        BinaryExpr::new(lhs.into_expr(), crate::Operator::And, rhs.into_expr()).into_expr()
×
161
    }
×
162
}
163

164
impl Display for BetweenExpr {
UNCOV
165
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
×
UNCOV
166
        write!(
×
UNCOV
167
            f,
×
UNCOV
168
            "({} {} {} {} {})",
×
169
            self.lower,
UNCOV
170
            self.options.lower_strict.to_operator(),
×
171
            self.arr,
UNCOV
172
            self.options.upper_strict.to_operator(),
×
173
            self.upper
174
        )
UNCOV
175
    }
×
176
}
177

178
impl AnalysisExpr for BetweenExpr {}
179

180
pub fn between(arr: ExprRef, lower: ExprRef, upper: ExprRef, options: BetweenOptions) -> ExprRef {
7✔
181
    BetweenExpr::new(arr, lower, upper, options).into_expr()
7✔
182
}
7✔
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