Skip to content

Clarify distinct_count is inexact in parquet.thrift - #628

Open
adriangb wants to merge 2 commits into
apache:masterfrom
adriangb:patch-1
Open

adriangb wants to merge 2 commits into
apache:masterfrom
adriangb:patch-1

Conversation

@adriangb

@adriangb adriangb commented Oct 7, 2026

Copy link
Copy Markdown

As per discussion in the sync call today and in https://lists.apache.org/thread.html/l8om71xjcv94x0z3hdvnbswk9ssyn2ks this clarifies the distinct_count to be estimated/inexact.

Updated comment for distinct_count to clarify that it provides an estimate of distinct values, which may vary.
@adriangb

adriangb commented Oct 7, 2026

Copy link
Copy Markdown
Author

cc @rdblue

Comment thread src/main/thrift/parquet.thrift Outdated
Comment on lines +293 to +294
* Estimated count of distinct values occurring.
* The estimate may be off in either direction by an underfined amount.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
* Estimated count of distinct values occurring.
* The estimate may be off in either direction by an underfined amount.
* count of distinct values occurring
* The value does not account for differences in equality or interpretation of values

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the suggestion Daniel. What does this buy in practice? Is this definition well defined enough that it unlocks some use cases that are otherwise blocked?

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.

I prefer @danielcweeks suggested wording. @adriangb IMO what this buys us is a clear and targeted fix saying that distinct_count is essentially not useful for types where equality is vague or has multiple interpretations. But for types that can be unambiguously compared (integers, strings), distinct_count remains an exact count if set. The initially proposed wording ("Estimated count of distinct values occurring...") is a much broader statement that's redefining this field, which feels like a breaking change. I also agree with the conversation on the mailing list that if estimate count is what we want, we should add another field.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I adopted the suggested wording in 3c7d0b7 since that seems to be the majority opinion.

I am however worried that moving forward with that is also a breaking change. Right now exactness is undefined or unknown. If we go with the wording in 3c7d0b7 any writer that used to write an estimate is now in violation of the spec.

It might be better to drop any attempt to define this field and instead make a new field and deprecate this one.

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.

IMO that would be a reasonable path forward

gunnarmorling added a commit to hardwood-hq/hardwood that referenced this pull request Oct 15, 2026
Hardwood's reader prunes on definition level histograms, including
IS NULL / IS NOT NULL on group columns, but its writer emits none, so
Hardwood cannot prune its own files on those predicates. The stage costs
little since the counts are observed while levels are encoded, so it
leads the open writer work ahead of S3 output and parallel encoding.

Stage 29 is parked on apache/parquet-format#628, whose outcome decides
whether an exact count is needed at all. The writer design doc pointed
at an unrelated issue for the missing histograms.
Reviewers prefer a targeted note on equality semantics over redefining
the field as an estimate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants