Repository navigation
[BP-2.4][FLINK-41370][table] Reject a literal index below 1 in SQL VARIANT array access - #29833
Merged
Merged
Conversation
…ray access (apache#29806) SQL `v[0]` and `v[-1]` on an array VARIANT returned NULL for every row, while the same literal fails during planning for a plain ARRAY and for `VARIANT.at(INT)` in the Table API. The index is 1-based, so such a literal can never address an element. The ARRAY literal-index check now also runs for a VARIANT index of any integer type. A computed index below 1 still returns NULL. Generated-by: Claude Code 2.1.319 (Claude Opus 5.5) (cherry picked from commit 485da2c)
Collaborator
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.
What is the purpose of the change
Backport of #29806 to release-2.4. On 2.4, SQL
v[0]andv[-1]on an array VARIANT return NULL for every row, while the same literal fails during planning for a plain ARRAY. 2.4.0 is the first release that can restore a compiled plan withv[i], so landing this before 2.4.0 means no released plan holds such a literal.Brief change log
variant '[' INT ']'entry insql_functions.ymlandsql_functions_zh.ymlconflicted, because release-2.4 still has the older wording and noVARIANT_GET. I kept the 2.4 text and added the new rule. The zh entry now has the same English text as the en entry, as on master.Verifying this change
VariantSemanticTest(25 tests) andArrayTypeTest(8 tests) in flink-table-planner pass on this branch.Does this pull request potentially affect one of the following parts:
@Public(Evolving): no. A query with a literal VARIANT index below 1 now fails during planning, see the release note on FLINK-41370.Documentation
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code 2.1.319 (Claude Opus 5.5)