• 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

86.49
/vortex-array/src/stats/flatbuffers.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
use flatbuffers::{FlatBufferBuilder, Follow, WIPOffset};
5
use vortex_dtype::{DType, Nullability, PType};
6
use vortex_error::{VortexError, vortex_bail};
7
use vortex_flatbuffers::{ReadFlatBuffer, WriteFlatBuffer, array as fba};
8
use vortex_scalar::ScalarValue;
9

10
use crate::stats::{Precision, Stat, StatsSet};
11

12
impl WriteFlatBuffer for StatsSet {
13
    type Target<'t> = fba::ArrayStats<'t>;
14

15
    /// All statistics written must be exact
16
    fn write_flatbuffer<'fb>(
44✔
17
        &self,
44✔
18
        fbb: &mut FlatBufferBuilder<'fb>,
44✔
19
    ) -> WIPOffset<Self::Target<'fb>> {
44✔
20
        let (min_precision, min) = self
44✔
21
            .get(Stat::Min)
44✔
22
            .map(|min| {
44✔
23
                (
24
                    if min.is_exact() {
16✔
25
                        fba::Precision::Exact
16✔
26
                    } else {
UNCOV
27
                        fba::Precision::Inexact
×
28
                    },
29
                    Some(fbb.create_vector(&min.into_inner().to_protobytes::<Vec<u8>>())),
16✔
30
                )
31
            })
16✔
32
            .unwrap_or_else(|| (fba::Precision::Inexact, None));
44✔
33

34
        let (max_precision, max) = self
44✔
35
            .get(Stat::Max)
44✔
36
            .map(|max| {
44✔
37
                (
38
                    if max.is_exact() {
16✔
39
                        fba::Precision::Exact
16✔
40
                    } else {
UNCOV
41
                        fba::Precision::Inexact
×
42
                    },
43
                    Some(fbb.create_vector(&max.into_inner().to_protobytes::<Vec<u8>>())),
16✔
44
                )
45
            })
16✔
46
            .unwrap_or_else(|| (fba::Precision::Inexact, None));
44✔
47

48
        let sum = self
44✔
49
            .get(Stat::Sum)
44✔
50
            .and_then(Precision::as_exact)
44✔
51
            .map(|sum| fbb.create_vector(&sum.to_protobytes::<Vec<u8>>()));
44✔
52

53
        let stat_args = &fba::ArrayStatsArgs {
44✔
54
            min,
44✔
55
            min_precision,
44✔
56
            max,
44✔
57
            max_precision,
44✔
58
            sum,
44✔
59
            is_sorted: self
44✔
60
                .get_as::<bool>(Stat::IsSorted, &DType::Bool(Nullability::NonNullable))
44✔
61
                .and_then(Precision::as_exact),
44✔
62
            is_strict_sorted: self
44✔
63
                .get_as::<bool>(Stat::IsStrictSorted, &DType::Bool(Nullability::NonNullable))
44✔
64
                .and_then(Precision::as_exact),
44✔
65
            is_constant: self
44✔
66
                .get_as::<bool>(Stat::IsConstant, &DType::Bool(Nullability::NonNullable))
44✔
67
                .and_then(Precision::as_exact),
44✔
68
            null_count: self
44✔
69
                .get_as::<u64>(Stat::NullCount, &PType::U64.into())
44✔
70
                .and_then(Precision::as_exact),
44✔
71
            uncompressed_size_in_bytes: self
44✔
72
                .get_as::<u64>(Stat::UncompressedSizeInBytes, &PType::U64.into())
44✔
73
                .and_then(Precision::as_exact),
44✔
74
            nan_count: self
44✔
75
                .get_as::<u64>(Stat::NaNCount, &PType::U64.into())
44✔
76
                .and_then(Precision::as_exact),
44✔
77
        };
44✔
78

79
        fba::ArrayStats::create(fbb, stat_args)
44✔
80
    }
44✔
81
}
82

83
impl ReadFlatBuffer for StatsSet {
84
    type Source<'a> = fba::ArrayStats<'a>;
85
    type Error = VortexError;
86

87
    fn read_flatbuffer<'buf>(
14✔
88
        fb: &<Self::Source<'buf> as Follow<'buf>>::Inner,
14✔
89
    ) -> Result<Self, Self::Error> {
14✔
90
        let mut stats_set = StatsSet::default();
14✔
91

92
        for stat in Stat::all() {
126✔
93
            match stat {
126✔
94
                Stat::IsConstant => {
95
                    if let Some(is_constant) = fb.is_constant() {
14✔
96
                        stats_set.set(Stat::IsConstant, Precision::Exact(is_constant.into()));
2✔
97
                    }
12✔
98
                }
99
                Stat::IsSorted => {
100
                    if let Some(is_sorted) = fb.is_sorted() {
14✔
UNCOV
101
                        stats_set.set(Stat::IsSorted, Precision::Exact(is_sorted.into()));
×
102
                    }
14✔
103
                }
104
                Stat::IsStrictSorted => {
105
                    if let Some(is_strict_sorted) = fb.is_strict_sorted() {
14✔
UNCOV
106
                        stats_set.set(
×
UNCOV
107
                            Stat::IsStrictSorted,
×
UNCOV
108
                            Precision::Exact(is_strict_sorted.into()),
×
UNCOV
109
                        );
×
110
                    }
14✔
111
                }
112
                Stat::Max => {
113
                    if let Some(max) = fb.max() {
14✔
114
                        let value = ScalarValue::from_protobytes(max.bytes())?;
4✔
115
                        stats_set.set(
4✔
116
                            Stat::Max,
4✔
117
                            match fb.max_precision() {
4✔
118
                                fba::Precision::Exact => Precision::Exact(value),
4✔
UNCOV
119
                                fba::Precision::Inexact => Precision::Inexact(value),
×
120
                                other => vortex_bail!("Corrupted max_precision field: {other:?}"),
×
121
                            },
122
                        );
123
                    }
10✔
124
                }
125
                Stat::Min => {
126
                    if let Some(min) = fb.min() {
14✔
127
                        let value = ScalarValue::from_protobytes(min.bytes())?;
4✔
128
                        stats_set.set(
4✔
129
                            Stat::Min,
4✔
130
                            match fb.min_precision() {
4✔
131
                                fba::Precision::Exact => Precision::Exact(value),
4✔
UNCOV
132
                                fba::Precision::Inexact => Precision::Inexact(value),
×
133
                                other => vortex_bail!("Corrupted min_precision field: {other:?}"),
×
134
                            },
135
                        );
136
                    }
10✔
137
                }
138
                Stat::NullCount => {
139
                    if let Some(null_count) = fb.null_count() {
14✔
140
                        stats_set.set(Stat::NullCount, Precision::Exact(null_count.into()));
4✔
141
                    }
10✔
142
                }
143
                Stat::UncompressedSizeInBytes => {
144
                    if let Some(uncompressed_size_in_bytes) = fb.uncompressed_size_in_bytes() {
14✔
UNCOV
145
                        stats_set.set(
×
UNCOV
146
                            Stat::UncompressedSizeInBytes,
×
UNCOV
147
                            Precision::Exact(uncompressed_size_in_bytes.into()),
×
UNCOV
148
                        );
×
149
                    }
14✔
150
                }
151
                Stat::Sum => {
152
                    if let Some(sum) = fb.sum() {
14✔
153
                        stats_set.set(
4✔
154
                            Stat::Sum,
4✔
155
                            Precision::Exact(ScalarValue::from_protobytes(sum.bytes())?),
4✔
156
                        );
157
                    }
10✔
158
                }
159
                Stat::NaNCount => {
160
                    if let Some(nan_count) = fb.nan_count() {
14✔
161
                        stats_set.set(
2✔
162
                            Stat::NaNCount,
2✔
163
                            Precision::Exact(ScalarValue::from(nan_count)),
2✔
164
                        );
2✔
165
                    }
12✔
166
                }
167
            }
168
        }
169

170
        Ok(stats_set)
14✔
171
    }
14✔
172
}
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