Repository navigation
fix: [branch-1.2] cast a non-INT GetArrayItem index to INT like Spark (#7552) - #7654
Merged
Merged
Conversation
* fix: cast a non-INT `GetArrayItem` index to INT like Spark * test: literal array with a non-INT column index in GetArrayItem (cherry picked from commit c40c8c2)
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?
Backport of #7552 to
branch-1.2. Closes #7551 on this branch.Rationale for this change
arr[i]fails in Comet wheniis not an INT, while Spark accepts any integer type there, for examplesort_array(collect_list(x))[floor(count(*) / 2)], sincefloorreturns a BIGINT (#7551,priority:high).branch-1.2has the sameCometGetArrayItemserde and the sameListExtractnative expression. See #7552 for the full analysis.What changes are included in this PR?
Cherry-pick of c40c8c2 (
git cherry-pick -x) with no conflicts and no adaptations. The diff against the source commit is identical apart from line numbers and blob hashes.CometGetArrayItemcasts a non-INT index to INT with the legacy cast, which keeps the low 32 bits of a BIGINT as Spark's conversion does, before passing it toListExtract. It comes with the source PR's new cases in theget_array_item.sqlandget_array_item_ansi.sqlSQL file tests.Other release branches:
branch-1.2is the newest release branch, so there is no newer one to port to. Whetherbranch-1.1needs a backport is not part of this PR.How are these changes tested?
On this branch, with JDK 17 and the default Spark profile:
./mvnw test-compilesucceeds, and theget_array_item.sqlandget_array_item_ansi.sqlfile tests pass (2 tests, 0 failures). No native source changed. Withspark/src/mainreverted tobranch-1.2's version, both file tests fail, so the branch has the bug and the tests catch it.