Repository navigation
[BP-2.4][FLINK-40936][table] Reject VARIANT elements and keys in functions and operators that compare them - #29610
Merged
Conversation
…d operators that compare them (apache#29416) Flink compares VARIANT values by their binary encoding, but one value has many encodings. So functions and operators that compare array elements, map keys or collected values returned wrong results for equal VARIANT values. ComparableTypeValidator now rejects VARIANT elements and keys in the array and map functions that compare them, such as ARRAY_CONTAINS and MAP_CONTAINS_KEY. It also rejects a VARIANT key in a map lookup m[k] and a VARIANT argument of COLLECT. An array index and a field access on a VARIANT stay allowed. The check lives in the validator, not in each function's input type strategy, since a future VARIANT equality may remove it. LogicalTypeChecks.areComparable now rejects every type that is not comparable, so GREATEST, LEAST and Table API comparisons reject VARIANT too. The array and map functions check it again during code generation. So a restored compiled plan that calls them on VARIANT now fails before the job is submitted, instead of returning wrong results. A user SpecializedFunction that builds an = evaluator on VARIANT fails too. KeyTypeValidator is now ComparableTypeValidator, and isComparableKeyType is now isComparableType, since both cover every comparison, not only keys. (cherry picked from commit 5c9455b)
twalthr
approved these changes
Oct 26, 2026
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 #29416 to release-2.4. FLINK-40910 (#29411) is already on release-2.4, so 2.4 rejects VARIANT in GROUP BY, joins and comparisons. Without this commit, 2.4 still accepts VARIANT elements and keys in ARRAY_CONTAINS, MAP_CONTAINS_KEY,
m[k], COLLECT and the other functions that compare them, and returns wrong results for equal VARIANT values.Brief change log
Verifying this change
LogicalTypeChecksTest,ComparableInputTypeStrategyTest,ComparableTypeValidatorTest,CastFunctionITCase,MapFunctionITCaseandCollectionFunctionsITCasepass on this branch.Does this pull request potentially affect one of the following parts:
@Public(Evolving): no. Calls of these functions and operators with VARIANT elements or keys now fail, see the release note on FLINK-40936.Documentation
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code 2.1.310 (Claude Opus 5.5)