Skip to content

[Parquet] Add row group distinct counts to StatisticsConverter - #10652

Open
Rich-T-kid wants to merge 4 commits into
apache:mainfrom
Rich-T-kid:investigate-parquet-stats
Open

[Parquet] Add row group distinct counts to StatisticsConverter#10652
Rich-T-kid wants to merge 4 commits into
apache:mainfrom
Rich-T-kid:investigate-parquet-stats

Conversation

@Rich-T-kid

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

see #10650

What changes are included in this PR?

Added StatisticsConverter::row_group_distinct_counts() to the parquet crate, which reads the distinct_count field from row group statistics and returns a UInt64Array with one entry per row group.

Are these changes tested?

yes this PR includes two test that assert that row group stats are being propogated

Are there any user-facing changes?

yes, adds new public method for reading row group distinct stats

Adds `StatisticsConverter::row_group_distinct_counts()` which reads the
`distinct_count` field from parquet row group statistics and returns a
`UInt64Array` with one entry per row group (null where the field is absent).

This mirrors the existing `row_group_null_counts` and `row_group_nan_counts`
methods and unblocks DataFusion from populating `ColumnStatistics::distinct_count`
via `statistics_from_parquet_metadata`. Previously this was always
`Precision::Absent` for parquet files regardless of whether the file contained
the field.

Non-arrow-rs writers (parquet-java, parquet-cpp) may already populate
`distinct_count` in the file footer, so the read path is immediately useful
without any write-side changes.
@github-actions github-actions Bot added the parquet Changes to the parquet crate label Aug 11, 2026
@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

🤔 datafusion does do something similar here https://github.com/apache/datafusion/blob/041a71671c7a505a2e3ed58689a20137c8f3d172/datafusion/datasource-parquet/src/metadata.rs#L835, but with this PR we allow arrow-rs user to do it directly as well make a consistent api.

@etseidl etseidl changed the title [Parquet] Add row group column stats [Parquet] Add row group distinct counts to StatisticsConverter Aug 11, 2026

@etseidl etseidl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems sensible to me, esp. if there are writers that actually populate this statistic.

How to tackle the write side of this is still a matter of debate. 😅

@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

This seems sensible to me, esp. if there are writers that actually populate this statistic.

How to tackle the write side of this is still a matter of debate. 😅

@etseidl i just ran a simple implementation gated by a boolean flag and it ranges from 1.4x-8.8x slower depending on the data type.

@etseidl

etseidl commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

i just ran a simple implementation gated by a boolean flag and it ranges from 1.4x-8.8x slower depending on the data type.

That's quite the hit, glad it's gated. But I can see a use for write-once-read-many scenarios where you'd likely want the cardinality and are willing to pay for it.

@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

I'll try and see if I can make it more performant and push up the PR tomorrow 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet Changes to the parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants