Skip to content

[BP-2.4][FLINK-40936][table] Reject VARIANT elements and keys in functions and operators that compare them - #29610

Merged
raminqaf merged 1 commit into
apache:release-2.4from
raminqaf:FLINK-40936-bp-2.4
Oct 26, 2026
Merged

raminqaf merged 1 commit into
apache:release-2.4from
raminqaf:FLINK-40936-bp-2.4

Conversation

@raminqaf

Copy link
Copy Markdown
Contributor

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

  • Cherry-pick of 5c9455b, applied without conflicts

Verifying this change

LogicalTypeChecksTest, ComparableInputTypeStrategyTest, ComparableTypeValidatorTest, CastFunctionITCase, MapFunctionITCase and CollectionFunctionsITCase pass on this branch.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no. Calls of these functions and operators with VARIANT elements or keys now fail, see the release note on FLINK-40936.
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: yes. A restored compiled plan that calls one of the array or map functions on VARIANT elements or keys fails when it is executed, as in [FLINK-40936][table] Reject VARIANT elements and keys in functions and operators that compare them #29416.
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Code 2.1.310 (Claude Opus 5.5)

…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)
@flinkbot

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@raminqaf
raminqaf merged commit 417b615 into apache:release-2.4 Oct 26, 2026
1 check passed
@raminqaf
raminqaf deleted the FLINK-40936-bp-2.4 branch October 26, 2026 10:24
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