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

vortex-data / vortex / 17004123171

16 Aug 2025 04:07AM UTC coverage: 87.913%. First build
17004123171

Pull #4246

github

web-flow
Merge 365e87e54 into a23a73000
Pull Request #4246: feat[spark]: write support in VortexDataSourceV2

12 of 13 new or added lines in 3 files covered. (92.31%)

56580 of 64359 relevant lines covered (87.91%)

628883.28 hits per line

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

84.0
/vortex-dtype/src/datetime/unit.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

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

6
use jiff::Span;
7
use num_enum::IntoPrimitive;
8
use vortex_error::{VortexError, VortexResult, vortex_bail};
9

10
/// Time units for temporal data.
11
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd, IntoPrimitive)]
12
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
13
#[repr(u8)]
14
pub enum TimeUnit {
15
    /// Nanoseconds
16
    Ns = 0,
17
    /// Microseconds
18
    Us = 1,
19
    /// Milliseconds
20
    Ms = 2,
21
    /// Seconds
22
    S = 3,
23
    /// Days
24
    D = 4,
25
}
26

27
impl TryFrom<u8> for TimeUnit {
28
    type Error = VortexError;
29

30
    fn try_from(value: u8) -> Result<Self, Self::Error> {
585,456✔
31
        match value {
585,456✔
32
            0 => Ok(TimeUnit::Ns),
1,320✔
33
            1 => Ok(TimeUnit::Us),
2,161✔
34
            2 => Ok(TimeUnit::Ms),
13,644✔
35
            3 => Ok(TimeUnit::S),
565,760✔
36
            4 => Ok(TimeUnit::D),
2,571✔
NEW
37
            _ => vortex_bail!("invalid time unit: {value}u8"),
×
38
        }
39
    }
585,456✔
40
}
41

42
impl TimeUnit {
43
    /// Convert to a Jiff span.
44
    pub fn to_jiff_span(&self, v: i64) -> VortexResult<Span> {
280✔
45
        Ok(match self {
280✔
46
            TimeUnit::Ns => Span::new().try_nanoseconds(v)?,
×
47
            TimeUnit::Us => Span::new().try_microseconds(v)?,
×
48
            TimeUnit::Ms => Span::new().try_milliseconds(v)?,
×
49
            TimeUnit::S => Span::new().try_seconds(v)?,
160✔
50
            TimeUnit::D => Span::new().try_days(v)?,
120✔
51
        })
52
    }
280✔
53
}
54

55
impl Display for TimeUnit {
56
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
280✔
57
        match self {
280✔
58
            Self::Ns => write!(f, "ns"),
40✔
59
            Self::Us => write!(f, "µs"),
40✔
60
            Self::Ms => write!(f, "ms"),
80✔
61
            Self::S => write!(f, "s"),
40✔
62
            Self::D => write!(f, "days"),
80✔
63
        }
64
    }
280✔
65
}
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