Repository navigation
Group NaNs with different sign bits into one identity partition - #4434
Open
rahulsmahadev wants to merge 1 commit into
Open
rahulsmahadev wants to merge 1 commit into
rahulsmahadev wants to merge 1 commit into
Conversation
_determine_partitions groups identity values by raw bits, so NaNs with different sign bits form separate partitions. Each partition selects its rows with is_nan, which matches every NaN row, so each NaN row was written into every NaN partition. Canonicalize NaN in the partition helper column before grouping. Data is unchanged. Co-authored-by: Isaac <no-reply@databricks.com>
Contributor
Author
|
@rambleraptor, this is the NaN case of the duplication that #4274 fixes for -0.0 and 0.0, which you approved. @breken-ai, you added the NaN filter in #4030. Could you take a look when you have a chance? |
This branch has not been deployed
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
Bug: an identity partition on a
doubleorfloatcolumn writes each NaN row into every NaN partition file when the NaNs differ in the sign bit.float("nan")has the sign bit clear and0.0 * float("inf")has it set on x86._determine_partitionsgroups by the raw bits, so these are two partitions. Each one selects its rows withis_nan, which matches every NaN row:Fix: canonicalize NaN in the partition helper column before the group by, so every NaN is one partition value, as the spec defines partition equality (Scan Planning). The data column keeps its bits.
Java: Spark computes each row's
PartitionKey, thenFanoutWriterandClusteredWriteruseComparators.forTypeto group all NaNs together. This PR gives_determine_partitions, shared by append and rewrites, the same grouping.Remaining differences from Java:
-0.0and0.0have the same duplication. Write each row once when an identity partition has both -0.0 and 0.0 #4274 fixes that in_partition_value_filter, and this PR leaves that function alone.Are these changes tested?
Yes, added
test_determine_partitions_identity_nan_sign_bits(double and float,tests/io/test_pyarrow.py), and the existingtest_append_nan_to_identity_partitioned_table(append and scan,tests/catalog/test_catalog_behaviors.py) now has a-NaNvalue. Both fail on main, where the scan returns ids 2 and 4 twice and_determine_partitionsreturns two NaN partitions, and pass with this change.Are there any user-facing changes?
Yes, appends no longer write duplicate rows for NaN values with different sign bits.
Please add the
changeloglabel.This pull request and its description were written by Isaac.