[FLINK-37926][table] Support casting from VARIANT to MAP - #29118
Merged
Conversation
Collaborator
raminqaf
force-pushed
the
FLINK-37926-variant-to-map
branch
from
September 6, 2026 11:28
31e2b3f to
48e2b5f
Compare
raminqaf
force-pushed
the
FLINK-37926-variant-to-map
branch
3 times, most recently
from
September 7, 2026 08:33
44c712e to
1683ccc
Compare
raminqaf
force-pushed
the
FLINK-37926-variant-to-map
branch
from
September 7, 2026 08:36
1683ccc to
0c706e9
Compare
raminqaf
marked this pull request as ready for review
September 7, 2026 08:37
twalthr
approved these changes
Sep 7, 2026
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
This pull request adds
CASTandTRY_CASTfromVARIANTtoMAP<STRING, V>. It is the last of the stacked constructed-cast PRs and builds on the same design:ARRAY(merged),ROW/STRUCTURED(#29092), and nowMAP. It is stacked on #29092 and should be reviewed and merged after it.MAPis the schemaless read of an object: unlikeROW, no field is named in advance, so it is the way to read an object whose keys are dynamic or unknown at query time.Key semantics:
Vby the sameVARIANT-to-value rules, recursively.NULLwhenVis nullable and fails the cast whenVisNOT NULL. An empty object casts to an empty map.MAP<STRING, VARIANT>value type is the identity, so a variant null is kept as a variant null rather than downgraded to SQLNULL. This matchesARRAY<VARIANT>and aROWwithVARIANTfields.TRY_CASTreturnsNULLfor the entire value on any failure.Brief change log
VariantToMapCastRulethat casts a variant object toMAP<STRING, V>, mapping field names to keys and casting each value with the existing VARIANT-to-value rules.LogicalTypeCastswhen the key is a character string andVARIANTcasts to the value type.MAPcast and markVARIANT→MAPin the cast-support matrix.Verifying this change
This change added tests and can be verified as follows:
CastRulesTest: key/value mapping, an empty object, a non-object input, andMAP<STRING, VARIANT>with and without a variant null value.CastFunctionITCase: end-to-end SQL and Table API cases (the Table API cases use theparseJson()expression method).LogicalTypeCastsTestandCastRuleProviderTest: castability and rule resolution, including the non-string-key rejection.Does this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation
Was generative AI tooling used to co-author this PR?
Generated-by: [Tool Name and Version]