Repository navigation
fix: downcast to FixedSizeBinaryArray in CASE bytes lookup table - #26151
Open
jdymitarai wants to merge 1 commit into
Open
jdymitarai wants to merge 1 commit into
jdymitarai wants to merge 1 commit into
Conversation
In BytesLikeIndexMap, DataType::FixedSizeBinary was mistakenly downcasting using �rray.as_binary::<i64>() rather than �rray.as_fixed_size_binary(). When a CASE expression with multiple FixedSizeBinary literal WHEN clauses was evaluated via LiteralLookupTable, this triggered a panic in �rrow-array during cast. Closes apache#26012.
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.
Which issue does this PR close?
Closes #26012.
Rationale for this change
When evaluating
CASE <expr> WHEN <literal> ...with two or more literal branches of byte-like types, DataFusion optimizes branch evaluation usingLiteralLookupTablebacked byBytesLikeIndexMap.In
try_get_bytes_iterator, the match arm forDataType::FixedSizeBinary(_)was accidentally callingarray.as_binary::<i64>().into_iter(), which attempts to downcast toGenericBinaryArray<i64>(LargeBinaryArray). When presented with aFixedSizeBinaryArray, Arrow's downcast fails and panics:Note that the dictionary arm in the same file (
get_bytes_iterator_for_dictionary) already used.downcast_dict::<FixedSizeBinaryArray>(), confirming this was an oversight in the flat array branch.What changes are included in this PR?
try_get_bytes_iteratorforDataType::FixedSizeBinary(_)to usearray.as_fixed_size_binary().into_iter().datafusion/physical-expr/src/expressions/case.rscovering bothFixedSizeBinaryand dictionary-encodedDictionary(UInt8, FixedSizeBinary)CASE evaluation.datafusion/sqllogictest/test_files/case.sltreproducing the issue query and verifying matching/non-matching branches.Are these changes tested?
Yes:
case_with_expr_fixed_size_binaryandcase_with_expr_fixed_size_binary_dictionaryindatafusion-physical-expr.case.slt.cargo testand sqllogictest.Are there any user-facing changes?
No API changes. Fixes a panic when evaluating
CASEexpressions withFixedSizeBinaryliteral branches.