Skip to content

Commit be5b70f

Browse files
committed
address comment
1 parent a003ed0 commit be5b70f

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

parquet-variant-compute/src/type_conversion.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ pub(crate) trait TimestampFromVariant: ArrowTimestampType {
7676
}
7777

7878
macro_rules! impl_timestamp_from_variant {
79-
($timestamp_type:ty, {
80-
$(($variant_pattern:pat, $conversion:expr)),+ $(,)?
81-
}) => {
79+
($timestamp_type:ty,
80+
$( $variant_pattern:pat => $conversion:expr ),+ $(,)?
81+
) => {
8282
impl TimestampFromVariant for $timestamp_type {
8383
fn from_variant(variant: &Variant<'_, '_>) -> Option<Self::Native> {
8484
match variant {
@@ -92,17 +92,19 @@ macro_rules! impl_timestamp_from_variant {
9292
};
9393
}
9494

95-
impl_timestamp_from_variant!(TimestampMicrosecondType, {
96-
(Variant::TimestampMicros(t), Some(t.timestamp_micros())),
97-
(Variant::TimestampNtzMicros(t), Some(t.and_utc().timestamp_micros())),
98-
});
99-
100-
impl_timestamp_from_variant!(TimestampNanosecondType, {
101-
(Variant::TimestampMicros(t), Some(t.timestamp_micros()).map(|t| t * 1000)),
102-
(Variant::TimestampNtzMicros(t), Some(t.and_utc().timestamp_micros()).map(|t| t * 1000)),
103-
(Variant::TimestampNanos(t), t.timestamp_nanos_opt()),
104-
(Variant::TimestampNtzNanos(t), t.and_utc().timestamp_nanos_opt()),
105-
});
95+
impl_timestamp_from_variant!(
96+
TimestampMicrosecondType,
97+
Variant::TimestampMicros(t) => Some(t.timestamp_micros()),
98+
Variant::TimestampNtzMicros(t) => Some(t.and_utc().timestamp_micros()),
99+
);
100+
101+
impl_timestamp_from_variant!(
102+
TimestampNanosecondType,
103+
Variant::TimestampMicros(t) => Some(t.timestamp_micros()).map(|t| t * 1000),
104+
Variant::TimestampNtzMicros(t) => Some(t.and_utc().timestamp_micros()).map(|t| t * 1000),
105+
Variant::TimestampNanos(t) => t.timestamp_nanos_opt(),
106+
Variant::TimestampNtzNanos(t) => t.and_utc().timestamp_nanos_opt(),
107+
);
106108

107109
/// Convert the value at a specific index in the given array into a `Variant`.
108110
macro_rules! non_generic_conversion_single_value {

parquet-variant-compute/src/variant_to_arrow.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,10 @@ macro_rules! define_variant_to_primitive_builder {
345345
impl<$lifetime $(, $generic: $bound+ )?> $name<$lifetime $(, $generic )?> {
346346
fn new(
347347
cast_options: &$lifetime CastOptions<$lifetime>,
348-
$array_param: usize
348+
$array_param: usize,
349349
// add this so that $init_expr can use it
350-
$(, $field: $field_type)?) -> Self {
350+
$( $field: $field_type, )?
351+
) -> Self {
351352
Self {
352353
builder: $init_expr,
353354
cast_options,

0 commit comments

Comments
 (0)