• 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/proto.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
use itertools::Itertools;
5
use vortex_error::{VortexResult, vortex_err};
6
use vortex_proto::expr as pb;
7

8
use crate::registry::ExprRegistry;
9
use crate::{ExprRef, VortexExpr};
10

11
pub trait ExprSerializeProtoExt {
12
    /// Serialize the expression to its protobuf representation.
13
    fn serialize_proto(&self) -> VortexResult<pb::Expr>;
14
}
15

16
impl ExprSerializeProtoExt for dyn VortexExpr + '_ {
UNCOV
17
    fn serialize_proto(&self) -> VortexResult<pb::Expr> {
×
UNCOV
18
        let children = self
×
UNCOV
19
            .children()
×
UNCOV
20
            .into_iter()
×
UNCOV
21
            .map(|child| child.serialize_proto())
×
UNCOV
22
            .try_collect()?;
×
23

UNCOV
24
        let metadata = self.metadata().ok_or_else(|| {
×
25
            vortex_err!("Expression '{}' is not serializable: {}", self.id(), self)
×
26
        })?;
×
27

UNCOV
28
        Ok(pb::Expr {
×
UNCOV
29
            id: self.id().to_string(),
×
UNCOV
30
            children,
×
UNCOV
31
            metadata: Some(metadata),
×
UNCOV
32
        })
×
UNCOV
33
    }
×
34
}
35

36
/// Deserialize a [`ExprRef`] from the protobuf representation.
UNCOV
37
pub fn deserialize_expr_proto(expr: &pb::Expr, registry: &ExprRegistry) -> VortexResult<ExprRef> {
×
UNCOV
38
    let expr_id = expr.id.as_str();
×
UNCOV
39
    let encoding = registry
×
UNCOV
40
        .get(expr_id)
×
UNCOV
41
        .ok_or_else(|| vortex_err!("unknown expression id: {}", expr_id))?;
×
42

UNCOV
43
    let children = expr
×
UNCOV
44
        .children
×
UNCOV
45
        .iter()
×
UNCOV
46
        .map(|e| deserialize_expr_proto(e, registry))
×
UNCOV
47
        .collect::<VortexResult<Vec<_>>>()?;
×
48

UNCOV
49
    encoding.build(expr.metadata(), children)
×
UNCOV
50
}
×
51

52
#[cfg(test)]
53
mod tests {
54
    use prost::Message;
55
    use vortex_array::compute::{BetweenOptions, StrictComparison};
56
    use vortex_proto::expr as pb;
57

58
    use crate::proto::{ExprSerializeProtoExt, deserialize_expr_proto};
59
    use crate::registry::ExprRegistryExt;
60
    use crate::{ExprRef, ExprRegistry, and, between, eq, get_item, lit, or, root};
61

62
    #[test]
63
    fn expression_serde() {
64
        let registry = ExprRegistry::default();
65
        let expr: ExprRef = or(
66
            and(
67
                between(
68
                    lit(1),
69
                    root(),
70
                    get_item("a", root()),
71
                    BetweenOptions {
72
                        lower_strict: StrictComparison::Strict,
73
                        upper_strict: StrictComparison::Strict,
74
                    },
75
                ),
76
                lit(1),
77
            ),
78
            eq(lit(1), root()),
79
        );
80

81
        let s_expr = expr.serialize_proto().unwrap();
82
        let buf = s_expr.encode_to_vec();
83
        let s_expr = pb::Expr::decode(buf.as_slice()).unwrap();
84
        let deser_expr = deserialize_expr_proto(&s_expr, &registry).unwrap();
85

86
        assert_eq!(&deser_expr, &expr);
87
    }
88
}
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