Skip to content

Commit ac88560

Browse files
authored
refactor: use logical type ref when getting stats (#4019)
# Description The `logical_type` field on parquet column descriptor is deprecated. This PR updates our code to use the new recommended API `logical_type_ref`. Signed-off-by: Robert Pack <robstar.pack@gmail.com>
1 parent cba0a9d commit ac88560

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

crates/core/src/writer/stats.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ fn stats_from_metadata(
196196
);
197197
None
198198
} else {
199-
Some(AggregatedStats::from((s, &column_descr.logical_type())))
199+
Some(AggregatedStats::from((s, column_descr.logical_type_ref())))
200200
}
201201
})
202202
})
@@ -249,7 +249,7 @@ enum StatsScalar {
249249
impl StatsScalar {
250250
fn try_from_stats(
251251
stats: &Statistics,
252-
logical_type: &Option<LogicalType>,
252+
logical_type: Option<&LogicalType>,
253253
use_min: bool,
254254
) -> Result<Self, DeltaWriterError> {
255255
macro_rules! get_stat {
@@ -296,7 +296,7 @@ impl StatsScalar {
296296
};
297297
let timestamp = timestamp.ok_or(DeltaWriterError::StatsParsingFailed {
298298
debug_value: v.to_string(),
299-
logical_type: logical_type.clone(),
299+
logical_type: logical_type.cloned(),
300300
})?;
301301
Ok(Self::Timestamp(timestamp.naive_utc()))
302302
}
@@ -330,7 +330,7 @@ impl StatsScalar {
330330
}
331331
_ => Err(DeltaWriterError::StatsParsingFailed {
332332
debug_value: format!("{bytes:?}"),
333-
logical_type: logical_type.clone(),
333+
logical_type: logical_type.cloned(),
334334
}),
335335
}
336336
}
@@ -392,7 +392,7 @@ impl StatsScalar {
392392
}
393393
(stats, _) => Err(DeltaWriterError::StatsParsingFailed {
394394
debug_value: format!("{stats:?}"),
395-
logical_type: logical_type.clone(),
395+
logical_type: logical_type.cloned(),
396396
}),
397397
}
398398
}
@@ -453,8 +453,8 @@ struct AggregatedStats {
453453
pub null_count: u64,
454454
}
455455

456-
impl From<(&Statistics, &Option<LogicalType>)> for AggregatedStats {
457-
fn from(value: (&Statistics, &Option<LogicalType>)) -> Self {
456+
impl From<(&Statistics, Option<&LogicalType>)> for AggregatedStats {
457+
fn from(value: (&Statistics, Option<&LogicalType>)) -> Self {
458458
let (stats, logical_type) = value;
459459
let null_count = stats.null_count_opt().unwrap_or_default();
460460
if stats.min_bytes_opt().is_some() && stats.max_bytes_opt().is_some() {
@@ -843,7 +843,7 @@ mod tests {
843843
];
844844

845845
for (stats, logical_type, expected) in cases {
846-
let scalar = StatsScalar::try_from_stats(stats, logical_type, true).unwrap();
846+
let scalar = StatsScalar::try_from_stats(stats, logical_type.as_ref(), true).unwrap();
847847
let actual = serde_json::Value::from(scalar);
848848
assert_eq!(&actual, expected);
849849
}

0 commit comments

Comments
 (0)