Visitar URL original
GH-3574: Preserve null counts when min/max exceed limit by efegokdemir · Pull Request #3819 · apache/parquet-java · GitHub
Skip to content

GH-3574: Preserve null counts when min/max exceed limit - #3819

Open
efegokdemir wants to merge 2 commits into
apache:masterfrom
efegokdemir:codex/issue-3574-preserve-null-count
Open

efegokdemir wants to merge 2 commits into
apache:masterfrom
efegokdemir:codex/issue-3574-preserve-null-count

Conversation

@efegokdemir

@efegokdemir efegokdemir commented Sep 25, 2026 •

Copy link
Copy Markdown

Summary

Preserve null_count when a column's min/max statistics exceed the metadata size limit.

The size guard is needed for min/max values, but null_count is a compact independent statistic and remains useful to readers. This keeps the null count available without reintroducing oversized min/max metadata.

Changes

  • Emit null_count and nan_count before applying the min/max size limit for non-empty statistics.
  • Keep min/max omission behavior unchanged for oversized statistics.
  • Extend the binary statistics round-trip test to cover the preserved counts.

Testing

  • git diff --check passed.
  • The focused Maven test and Spotless check could not be run in this environment because no Java runtime is installed.

Compatibility note

For oversized, non-empty statistics, this changes the result from no statistics to counts without min/max. This is narrower than the unconditional null-count change reverted in #3688, but it still changes the previous all-or-nothing behavior. That compatibility question is under discussion.

Fixes #3574

Signed-off-by: Efe Gökdemir <efe@rexcode.co.uk>

@divjotarora divjotarora 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.

Thanks @efegokdemir!

@divjotarora divjotarora 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.

@efegokdemir My previous comment was not addressed, the current code still sets NaN count stats after the withinLimit check. I suggest we set null + NaN stats unconditionally and guard only min/max by the withinLimit check.

Proposed code:

formatStats.setNull_count(stats.getNumNulls());
if (stats.isNanCountSet()) {
    formatStats.setNan_count(stats.getNanCount());
}

if (!withinLimit(stats, truncateLength)) {
    return formatStats;
}

Signed-off-by: Efe Gökdemir <gokdemirefe1903@gmail.com>
@efegokdemir

Copy link
Copy Markdown
Author

Moved nan_count alongside null_count before the withinLimit early return; min/max remain size-gated. Added testNanCountIsPreservedWhenMinMaxExceedLimit, which forces the floating-point stats size check over the limit and verifies null count, NaN count, and omitted min/max. The pushed remote HEAD is d015ab76dd7d2c9bf79f5795d971ee1c3a568f23, and I verified both changed files at that SHA. git diff --check passed. Focused Maven/Spotless validation could not run: the wrapper reports “Unable to locate a Java Runtime” in this environment.

@wgtmac

wgtmac commented Oct 8, 2026

Copy link
Copy Markdown
Member

IIUC, this PR will hit the same issue as #3688?

cc @Fokko

@efegokdemir

Copy link
Copy Markdown
Author

Thanks for flagging #3688. At the current head, this change emits null_count and nan_count only for non-empty stats that fail the min/max size check; it still creates counts-only metadata where the old code emitted none. That is narrower than #3688’s unconditional behavior, but it does change the all-or-nothing contract. I have corrected the PR description to make that scope and compatibility question explicit. I will hold further code changes pending maintainer direction on whether this contract change is acceptable for #3574.

@divjotarora

Copy link
Copy Markdown
Contributor

@wgtmac Do you have a link to some discussion on why we reverted the previous change? #3688 has very little context

@wgtmac

wgtmac commented Oct 8, 2026

Copy link
Copy Markdown
Member

@divjotarora Sorry I cannot find any concrete evidence right now. If I remember it correctly, that change may break Iceberg to consume Parquet statistics. Perhaps @kevinjqliu @Fokko could provide more detail.

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.

null_count is omitted for large columns in parquet files

3 participants