Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for Timestamp data types in data page statistics. #11123

Conversation

efredine
Copy link
Contributor

@efredine efredine commented Jun 25, 2024

Which issue does this PR close?

Closes #11112.

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Covered by existing tests.

Are there any user-facing changes?

@github-actions github-actions bot added the core Core DataFusion crate label Jun 25, 2024
@efredine efredine force-pushed the Support-extracting-Timestamp-statistics-from-Parquet-Data-Pages branch from 8c6feae to c63875b Compare June 25, 2024 16:53
Ok(match unit {
TimeUnit::Second => {
Arc::new(match timezone {
Some(tz) => TimestampSecondArray::from_iter(iter).with_timezone(tz.clone()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Not tested, but perhaps with_timezone_opt could reduce some the repetitiveness of the code.

Copy link
Contributor

Choose a reason for hiding this comment

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

that is a great suggestion

@alamb
Copy link
Contributor

alamb commented Jun 25, 2024

Thanks @efredine and @tshauck -- I started CI on this PR

Some(tz) => TimestampNanosecondArray::from_iter(iter).with_timezone(tz.clone()),
None => TimestampNanosecondArray::from_iter(iter),
})
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied simplification using with_timezone_opt to the get_statistics macro as well.

@@ -713,6 +692,15 @@ macro_rules! get_data_page_statistics {
)),
Some(DataType::Float32) => Ok(Arc::new(Float32Array::from_iter([<$stat_type_prefix Float32DataPageStatsIterator>]::new($iterator).flatten()))),
Some(DataType::Float64) => Ok(Arc::new(Float64Array::from_iter([<$stat_type_prefix Float64DataPageStatsIterator>]::new($iterator).flatten()))),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this repeated code be extracted? I assume it would need to be put into a macro?

Copy link
Contributor

Choose a reason for hiding this comment

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

Which repeated code do you mean?

If you wnated to more fully macroize this table and avoid repetition that sounds like a great idea to me (though perhaps as a follow on PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The four lines in the match unit expression are exactly the same in both macros.

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks again @efredine and @tshauck

@@ -713,6 +692,15 @@ macro_rules! get_data_page_statistics {
)),
Some(DataType::Float32) => Ok(Arc::new(Float32Array::from_iter([<$stat_type_prefix Float32DataPageStatsIterator>]::new($iterator).flatten()))),
Some(DataType::Float64) => Ok(Arc::new(Float64Array::from_iter([<$stat_type_prefix Float64DataPageStatsIterator>]::new($iterator).flatten()))),
Copy link
Contributor

Choose a reason for hiding this comment

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

Which repeated code do you mean?

If you wnated to more fully macroize this table and avoid repetition that sounds like a great idea to me (though perhaps as a follow on PR)

Copy link
Member

@Weijun-H Weijun-H left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @efredine

Comment on lines +358 to +361
TimeUnit::Second => Arc::new(TimestampSecondArray::from_iter(iter).with_timezone_opt(timezone.clone())),
TimeUnit::Millisecond => Arc::new(TimestampMillisecondArray::from_iter(iter).with_timezone_opt(timezone.clone())),
TimeUnit::Microsecond => Arc::new(TimestampMicrosecondArray::from_iter(iter).with_timezone_opt(timezone.clone())),
TimeUnit::Nanosecond => Arc::new(TimestampNanosecondArray::from_iter(iter).with_timezone_opt(timezone.clone())),
Copy link
Member

Choose a reason for hiding this comment

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

👍

@alamb alamb merged commit dd56dbe into apache:main Jun 26, 2024
23 checks passed
findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
…pache#11123)

* feat: Add support for Timestamp data types in data page statistics.

* Simplify array creation using with_timezone_opt.

---------

Co-authored-by: Eric Fredine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Timestamp Parquet Data Page Statistics
4 participants