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

vortex-data / vortex / 16935267080

13 Aug 2025 11:00AM UTC coverage: 24.312% (-63.3%) from 87.658%
16935267080

Pull #4226

github

web-flow
Merge 81b48c7fb into baa6ea202
Pull Request #4226: Support converting TimestampTZ to and from duckdb

0 of 2 new or added lines in 1 file covered. (0.0%)

20666 existing lines in 469 files now uncovered.

8726 of 35892 relevant lines covered (24.31%)

147.74 hits per line

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

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

4
use core::fmt;
5
use std::fmt::{Display, Formatter};
6

7
use vortex_array::compute;
8
use vortex_error::VortexError;
9
use vortex_proto::expr::binary_opts::BinaryOp;
10

11
/// Equalities, inequalities, and boolean operations over possibly null values.
12
///
13
/// For the equalities and inequalities, if either side is null, the result is null. The Boolean
14
/// operators obey [Kleene (three-valued) logic](https://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_logics).
15
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)]
16
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
17
pub enum Operator {
18
    // comparison
19
    Eq,
20
    NotEq,
21
    Gt,
22
    Gte,
23
    Lt,
24
    Lte,
25
    // boolean algebra
26
    And,
27
    Or,
28
    // arithmetic
29
    /// The sum of the arguments.
30
    ///
31
    /// Errs at runtime if the sum would overflow or underflow.
32
    ///
33
    /// The result is null at any index that either input is null.
34
    Add,
35
}
36

37
impl From<Operator> for i32 {
UNCOV
38
    fn from(value: Operator) -> Self {
×
UNCOV
39
        let op: BinaryOp = value.into();
×
UNCOV
40
        op.into()
×
UNCOV
41
    }
×
42
}
43

44
impl From<Operator> for BinaryOp {
UNCOV
45
    fn from(value: Operator) -> Self {
×
UNCOV
46
        match value {
×
UNCOV
47
            Operator::Eq => BinaryOp::Eq,
×
UNCOV
48
            Operator::NotEq => BinaryOp::NotEq,
×
UNCOV
49
            Operator::Gt => BinaryOp::Gt,
×
UNCOV
50
            Operator::Gte => BinaryOp::Gte,
×
UNCOV
51
            Operator::Lt => BinaryOp::Lt,
×
UNCOV
52
            Operator::Lte => BinaryOp::Lte,
×
UNCOV
53
            Operator::And => BinaryOp::And,
×
UNCOV
54
            Operator::Or => BinaryOp::Or,
×
UNCOV
55
            Operator::Add => BinaryOp::Add,
×
56
        }
UNCOV
57
    }
×
58
}
59

60
impl TryFrom<i32> for Operator {
61
    type Error = VortexError;
62

63
    fn try_from(value: i32) -> Result<Self, Self::Error> {
×
64
        Ok(BinaryOp::try_from(value)?.into())
×
65
    }
×
66
}
67

68
impl From<BinaryOp> for Operator {
UNCOV
69
    fn from(value: BinaryOp) -> Self {
×
UNCOV
70
        match value {
×
UNCOV
71
            BinaryOp::Eq => Operator::Eq,
×
UNCOV
72
            BinaryOp::NotEq => Operator::NotEq,
×
UNCOV
73
            BinaryOp::Gt => Operator::Gt,
×
UNCOV
74
            BinaryOp::Gte => Operator::Gte,
×
UNCOV
75
            BinaryOp::Lt => Operator::Lt,
×
UNCOV
76
            BinaryOp::Lte => Operator::Lte,
×
UNCOV
77
            BinaryOp::And => Operator::And,
×
UNCOV
78
            BinaryOp::Or => Operator::Or,
×
UNCOV
79
            BinaryOp::Add => Operator::Add,
×
80
        }
UNCOV
81
    }
×
82
}
83

84
impl Display for Operator {
UNCOV
85
    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
×
UNCOV
86
        let display = match &self {
×
UNCOV
87
            Operator::Eq => "=",
×
UNCOV
88
            Operator::NotEq => "!=",
×
UNCOV
89
            Operator::Gt => ">",
×
UNCOV
90
            Operator::Gte => ">=",
×
UNCOV
91
            Operator::Lt => "<",
×
UNCOV
92
            Operator::Lte => "<=",
×
UNCOV
93
            Operator::And => "and",
×
UNCOV
94
            Operator::Or => "or",
×
95
            Operator::Add => "+w",
×
96
        };
UNCOV
97
        Display::fmt(display, f)
×
UNCOV
98
    }
×
99
}
100

101
impl Operator {
102
    pub fn inverse(self) -> Option<Self> {
×
103
        match self {
×
104
            Operator::Eq => Some(Operator::NotEq),
×
105
            Operator::NotEq => Some(Operator::Eq),
×
106
            Operator::Gt => Some(Operator::Lte),
×
107
            Operator::Gte => Some(Operator::Lt),
×
108
            Operator::Lt => Some(Operator::Gte),
×
109
            Operator::Lte => Some(Operator::Gt),
×
110
            Operator::And | Operator::Or | Operator::Add => None,
×
111
        }
112
    }
×
113

114
    pub fn logical_inverse(self) -> Option<Self> {
×
115
        match self {
×
116
            Operator::And => Some(Operator::Or),
×
117
            Operator::Or => Some(Operator::And),
×
118
            _ => None,
×
119
        }
120
    }
×
121

122
    /// Change the sides of the operator, where changing lhs and rhs won't change the result of the operation
UNCOV
123
    pub fn swap(self) -> Self {
×
UNCOV
124
        match self {
×
125
            Operator::Eq => Operator::Eq,
×
126
            Operator::NotEq => Operator::NotEq,
×
UNCOV
127
            Operator::Gt => Operator::Lt,
×
UNCOV
128
            Operator::Gte => Operator::Lte,
×
UNCOV
129
            Operator::Lt => Operator::Gt,
×
130
            Operator::Lte => Operator::Gte,
×
131
            Operator::And => Operator::And,
×
132
            Operator::Or => Operator::Or,
×
133
            Operator::Add => Operator::Add,
×
134
        }
UNCOV
135
    }
×
136

137
    pub fn maybe_cmp_operator(self) -> Option<compute::Operator> {
×
138
        match self {
×
139
            Operator::Eq => Some(compute::Operator::Eq),
×
140
            Operator::NotEq => Some(compute::Operator::NotEq),
×
141
            Operator::Lt => Some(compute::Operator::Lt),
×
142
            Operator::Lte => Some(compute::Operator::Lte),
×
143
            Operator::Gt => Some(compute::Operator::Gt),
×
144
            Operator::Gte => Some(compute::Operator::Gte),
×
145
            _ => None,
×
146
        }
147
    }
×
148
}
149

150
impl From<compute::Operator> for Operator {
151
    fn from(cmp_operator: compute::Operator) -> Self {
×
152
        match cmp_operator {
×
153
            compute::Operator::Eq => Operator::Eq,
×
154
            compute::Operator::NotEq => Operator::NotEq,
×
155
            compute::Operator::Gt => Operator::Gt,
×
156
            compute::Operator::Gte => Operator::Gte,
×
157
            compute::Operator::Lt => Operator::Lt,
×
158
            compute::Operator::Lte => Operator::Lte,
×
159
        }
160
    }
×
161
}
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