Skip to content

fix: [branch-1.2] cast a non-INT GetArrayItem index to INT like Spark (#7552) - #7654

Merged
andygrove merged 2 commits into
apache:branch-1.2from
andygrove:backport-7552-branch-1.2
Nov 19, 2026
Merged

andygrove merged 2 commits into
apache:branch-1.2from
andygrove:backport-7552-branch-1.2

Conversation

@andygrove

Copy link
Copy Markdown
Member

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 when i is not an INT, while Spark accepts any integer type there, for example sort_array(collect_list(x))[floor(count(*) / 2)], since floor returns a BIGINT (#7551, priority:high). branch-1.2 has the same CometGetArrayItem serde and the same ListExtract native 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. CometGetArrayItem casts 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 to ListExtract. It comes with the source PR's new cases in the get_array_item.sql and get_array_item_ansi.sql SQL file tests.

Other release branches: branch-1.2 is the newest release branch, so there is no newer one to port to. Whether branch-1.1 needs 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-compile succeeds, and the get_array_item.sql and get_array_item_ansi.sql file tests pass (2 tests, 0 failures). No native source changed. With spark/src/main reverted to branch-1.2's version, both file tests fail, so the branch has the bug and the tests catch it.

akupchinskiy and others added 2 commits November 16, 2026 11:07
* 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)

@comphead comphead left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, great PR

@andygrove
andygrove merged commit e564ff4 into apache:branch-1.2 Nov 19, 2026
138 checks passed
@andygrove
andygrove deleted the backport-7552-branch-1.2 branch November 19, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants