GH-3406: fix Float16 statistics handling for NaN and zero values#3407
Open
HuaHuaY wants to merge 1 commit intoapache:masterfrom
Open
GH-3406: fix Float16 statistics handling for NaN and zero values#3407HuaHuaY wants to merge 1 commit intoapache:masterfrom
HuaHuaY wants to merge 1 commit intoapache:masterfrom
Conversation
wgtmac
reviewed
Feb 27, 2026
parquet-hadoop/src/test/java/org/apache/parquet/statistics/TestFloat16ReadWriteRoundTrip.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Fixes Float16 min/max edge cases so statistics and column indexes behave correctly when encountering NaN and signed-zero values, aligning behavior with Float/Double semantics and preventing invalid column indexes from being produced.
Changes:
- Add shared
Float16Binaryconstants for +0/-0 and reuse them in statistics/index logic. - Normalize Float16 min/max for signed zero and invalidate Float16 column indexes when NaN is present.
- Update/extend Hadoop round-trip tests to cover signed-zero normalization and NaN column-index invalidation.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| parquet-hadoop/src/test/java/org/apache/parquet/statistics/TestFloat16Statistics.java | Updates expected min/max placeholders for NaN stats handling. |
| parquet-hadoop/src/test/java/org/apache/parquet/statistics/TestFloat16ReadWriteRoundTrip.java | Adjusts zero-related expectations and adds a NaN column-index test expecting no index. |
| parquet-column/src/main/java/org/apache/parquet/schema/Float16.java | Introduces shared +0/-0 Float16 Binary constants. |
| parquet-column/src/main/java/org/apache/parquet/internal/column/columnindex/BinaryColumnIndexBuilder.java | Adds Float16-specific normalization (+0/-0) and NaN invalidation for column index creation. |
| parquet-column/src/main/java/org/apache/parquet/column/statistics/Statistics.java | Reuses Float16 constants and aligns NaN placeholder behavior with float/double builders. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
parquet-column/src/main/java/org/apache/parquet/schema/Float16.java
Outdated
Show resolved
Hide resolved
parquet-hadoop/src/test/java/org/apache/parquet/statistics/TestFloat16ReadWriteRoundTrip.java
Show resolved
Hide resolved
3809385 to
b42fcfb
Compare
b42fcfb to
a6faa03
Compare
Contributor
Author
|
Please take a look again @wgtmac |
Member
|
@gszadovszky Could you help review this as well? I think this fix makes a lot of sense to be consistent with what currently float and double types do. |
gszadovszky
approved these changes
Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
What changes are included in this PR?
Statistics<>.Float16BuilderandBinaryColumnIndexBuilder, this PR will adjust value when the min or max value is +0 or -0.BinaryColumnIndexBuilder, this PR will mark the column index is invalid when the min or max value is NaN.Statistics<>.Float16Builder, statistic will be changed to (+0.0, +0.0) which is the same behavior asDouble.Are these changes tested?
Yes.
Are there any user-facing changes?
Yes. This PR corrects the behavior about
Float16.Closes #3406