Skip to content

Commit 071eed1

Browse files
Weijun-Hfindepi
authored andcommitted
chore: Improve performance of Parquet statistics conversion (apache#10932)
1 parent 6357886 commit 071eed1

File tree

1 file changed

+4
-28
lines changed
  • datafusion/core/src/datasource/physical_plan/parquet

1 file changed

+4
-28
lines changed

datafusion/core/src/datasource/physical_plan/parquet/statistics.rs

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -303,24 +303,12 @@ macro_rules! get_statistics {
303303
))),
304304
DataType::Int8 => Ok(Arc::new(Int8Array::from_iter(
305305
[<$stat_type_prefix Int32StatsIterator>]::new($iterator).map(|x| {
306-
x.and_then(|x| {
307-
if let Ok(v) = i8::try_from(*x) {
308-
Some(v)
309-
} else {
310-
None
311-
}
312-
})
306+
x.and_then(|x| i8::try_from(*x).ok())
313307
}),
314308
))),
315309
DataType::Int16 => Ok(Arc::new(Int16Array::from_iter(
316310
[<$stat_type_prefix Int32StatsIterator>]::new($iterator).map(|x| {
317-
x.and_then(|x| {
318-
if let Ok(v) = i16::try_from(*x) {
319-
Some(v)
320-
} else {
321-
None
322-
}
323-
})
311+
x.and_then(|x| i16::try_from(*x).ok())
324312
}),
325313
))),
326314
DataType::Int32 => Ok(Arc::new(Int32Array::from_iter(
@@ -331,24 +319,12 @@ macro_rules! get_statistics {
331319
))),
332320
DataType::UInt8 => Ok(Arc::new(UInt8Array::from_iter(
333321
[<$stat_type_prefix Int32StatsIterator>]::new($iterator).map(|x| {
334-
x.and_then(|x| {
335-
if let Ok(v) = u8::try_from(*x) {
336-
Some(v)
337-
} else {
338-
None
339-
}
340-
})
322+
x.and_then(|x| u8::try_from(*x).ok())
341323
}),
342324
))),
343325
DataType::UInt16 => Ok(Arc::new(UInt16Array::from_iter(
344326
[<$stat_type_prefix Int32StatsIterator>]::new($iterator).map(|x| {
345-
x.and_then(|x| {
346-
if let Ok(v) = u16::try_from(*x) {
347-
Some(v)
348-
} else {
349-
None
350-
}
351-
})
327+
x.and_then(|x| u16::try_from(*x).ok())
352328
}),
353329
))),
354330
DataType::UInt32 => Ok(Arc::new(UInt32Array::from_iter(

0 commit comments

Comments
 (0)