Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions datafusion/core/src/datasource/physical_plan/parquet/statistics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,36 @@ macro_rules! get_data_page_statistics {
Decimal128Array::from_iter([<$stat_type_prefix Decimal128DataPageStatsIterator>]::new($iterator).flatten()).with_precision_and_scale(*precision, *scale)?)),
Some(DataType::Decimal256(precision, scale)) => Ok(Arc::new(
Decimal256Array::from_iter([<$stat_type_prefix Decimal256DataPageStatsIterator>]::new($iterator).flatten()).with_precision_and_scale(*precision, *scale)?)),
Some(DataType::Time32(unit)) => {
Ok(match unit {
TimeUnit::Second => Arc::new(Time32SecondArray::from_iter(
[<$stat_type_prefix Int32DataPageStatsIterator>]::new($iterator).flatten(),
)),
TimeUnit::Millisecond => Arc::new(Time32MillisecondArray::from_iter(
[<$stat_type_prefix Int32DataPageStatsIterator>]::new($iterator).flatten(),
)),
_ => {
let len = $iterator.count();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have referenced get_statistics macro to decide on returing a null array, my other idea was to conclued with unimplemented!().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You beat me to it ;-).

I think this can just be:

                        _ => new_empty_array(&DataType::Time32(unit.clone())),

And then you need to add new_empty_array into the use statement. Time64 gets a similar treatment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much cleaner. Thanks for the idea @efredine

// // don't know how to extract statistics, so return a null array
new_null_array($data_type.unwrap(), len)
}
})
}
Some(DataType::Time64(unit)) => {
Ok(match unit {
TimeUnit::Microsecond => Arc::new(Time64MicrosecondArray::from_iter(
[<$stat_type_prefix Int64DataPageStatsIterator>]::new($iterator).flatten(),
)),
TimeUnit::Nanosecond => Arc::new(Time64NanosecondArray::from_iter(
[<$stat_type_prefix Int64DataPageStatsIterator>]::new($iterator).flatten(),
)),
_ => {
let len = $iterator.count();
// // don't know how to extract statistics, so return a null array
new_null_array($data_type.unwrap(), len)
}
})
}
_ => unimplemented!()
}
}
Expand Down
8 changes: 4 additions & 4 deletions datafusion/core/tests/parquet/arrow_statistics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ async fn test_time32_second_diff_rg_sizes() {
expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0]), // Assuming 1 null per row group for simplicity
expected_row_counts: Some(UInt64Array::from(vec![4, 4, 4, 4])),
column_name: "second",
check: Check::RowGroup,
check: Check::Both,
}
.run();
}
Expand All @@ -1231,7 +1231,7 @@ async fn test_time32_millisecond_diff_rg_sizes() {
expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0]), // Assuming 1 null per row group for simplicity
expected_row_counts: Some(UInt64Array::from(vec![4, 4, 4, 4])),
column_name: "millisecond",
check: Check::RowGroup,
check: Check::Both,
}
.run();
}
Expand Down Expand Up @@ -1264,7 +1264,7 @@ async fn test_time64_microsecond_diff_rg_sizes() {
expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0]), // Assuming 1 null per row group for simplicity
expected_row_counts: Some(UInt64Array::from(vec![4, 4, 4, 4])),
column_name: "microsecond",
check: Check::RowGroup,
check: Check::Both,
}
.run();
}
Expand Down Expand Up @@ -1297,7 +1297,7 @@ async fn test_time64_nanosecond_diff_rg_sizes() {
expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0]), // Assuming 1 null per row group for simplicity
expected_row_counts: Some(UInt64Array::from(vec![4, 4, 4, 4])),
column_name: "nanosecond",
check: Check::RowGroup,
check: Check::Both,
}
.run();
}
Expand Down