Repository navigation
GH-55503: [C++] Fix Float16 memo table keys built from raw bits in dictionary unification and count_distinct - #55611
Open
AnuragRaut08 wants to merge 1 commit into
Conversation
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
Float16 dictionary unification and
count_distinctcan produce incorrect results because rawuint16_tstorage values are interpreted as numeric values instead of Float16 bit patterns.For example, the Float16 bit pattern
0x3C00, representing1.0, can be interpreted as15360.0when passed through the converting constructor.This causes dictionary values to be corrupted during dictionary unification and distinct Float16 values to be incorrectly merged by
count_distinct.What changes are included in this PR?
Float16::FromBits()when constructing memo table keys from raw Float16 values inDictionaryUnifierImpl::Unify.CountDistinctImpl::Consume.UnboxScalar<HalfFloatType>::Unboxto preserve the original bit representation.Are these changes tested?
Added regression tests:
TestDictionaryUnifier.HalfFloat: verifies unified dictionary values and transpose maps.TestCountDistinctKernel.HalfFloat: covers distinct Float16 values, duplicates, nulls, chunked arrays, and scalar input.Both regression tests were verified against the original implementation, where they reproduced the incorrect behavior.
Validation performed:
arrow-array-testarrow-compute-aggregate-testclang-format --dry-run --Werrorgit diff --checkAre there any user-facing changes?
Fixes incorrect Float16 values returned by dictionary unification and incorrect distinct counts for Float16 arrays.
This PR includes breaking changes to public APIs.
No.
This PR contains a "Critical Fix".
Yes. This fixes incorrect data produced by Float16 dictionary unification and
count_distinct.Was AI used for this PR?
PR code and description written by:
Reviewed before submission by:
combine_chunks,concat_arrays,unify_dictionaries, Feather) #55503