Skip to content

[FLINK-37924][table]Introduce Built-in Function to Access field or element in the Variant#27330

Merged
yunfengzhou-hub merged 12 commits intoapache:masterfrom
JinkunLiu:feature/FLINK-37924
Feb 2, 2026
Merged

[FLINK-37924][table]Introduce Built-in Function to Access field or element in the Variant#27330
yunfengzhou-hub merged 12 commits intoapache:masterfrom
JinkunLiu:feature/FLINK-37924

Conversation

@JinkunLiu
Copy link
Copy Markdown
Contributor

@JinkunLiu JinkunLiu commented Dec 9, 2025

What is the purpose of the change

Introduce a built-in function to access a field or element in a Variant. This is part of FLIP-521.

SQL Function Table Function Description
variant ‘[’ INT ‘]’ VARIANT.at(INT) If the VARIANT is an ARRAY value, returns a VARIANT whose value is the element at the specified index. Otherwise, this operation returns NULL
variant ‘[’ STRING ‘]’ VARIANT.at(STRING) If the VARIANT is a MAP value that has an element with this key, a VARIANT holding the associated value is returned. Otherwise, NULL is returned.

Brief change log

  • Support accessing VARIANT elements using [INT] or VARIANT.at(INT) when the VARIANT contains an ARRAY value in SQL or table expressions.
  • Support accessing VARIANT elements using ['STRING'] or VARIANT.at('STRING') when the VARIANT contains a MAP value in SQL or table expressions.

Verifying this change

This change added tests and can be verified as follows:

  • Added six new test at org.apache.flink.table.planner.plan.nodes.exec.stream.VariantSemanticTest

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)
  • 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: (no)
  • The S3 file system connector: (no)

@JinkunLiu JinkunLiu force-pushed the feature/FLINK-37924 branch from efb13bf to 53f4993 Compare December 9, 2025 16:27
@JinkunLiu JinkunLiu changed the title [FLINK-37924][sql]Introduce Built-in Function to Access field or element in the Variant [FLINK-37924][table]Introduce Built-in Function to Access field or element in the Variant Dec 9, 2025
@JinkunLiu JinkunLiu marked this pull request as ready for review December 9, 2025 16:28
@flinkbot
Copy link
Copy Markdown
Collaborator

flinkbot commented Dec 9, 2025

CI report:

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

@github-actions github-actions Bot added the community-reviewed PR has been reviewed by the community. label Dec 10, 2025
@JinkunLiu JinkunLiu marked this pull request as draft December 11, 2025 16:22
@JinkunLiu JinkunLiu marked this pull request as ready for review December 19, 2025 17:43
@JinkunLiu JinkunLiu requested a review from davidradl December 20, 2025 04:02
@JinkunLiu
Copy link
Copy Markdown
Contributor Author

JinkunLiu commented Dec 23, 2025

Hello @Sxnan Could you take a look at this PR when you have time? Thanks

Copy link
Copy Markdown
Contributor

@yunfengzhou-hub yunfengzhou-hub left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @JinkunLiu. Left some comments as below.

@JinkunLiu
Copy link
Copy Markdown
Contributor Author

Hi @yunfengzhou-hub, thanks for the review! I have updated the code according to your suggestions. Could you please take another look at this PR when you have time? Thank you very much!

Copy link
Copy Markdown
Contributor

@yunfengzhou-hub yunfengzhou-hub left a comment

Choose a reason for hiding this comment

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

Thanks for the update. Generally LGTM. Some minor comments are as below.

Comment thread docs/data/sql_functions.yml
@JinkunLiu
Copy link
Copy Markdown
Contributor Author

Hi @davidradl , thanks for the review! Could you take an another look. Thanks

Copy link
Copy Markdown
Contributor

@xuyangzhong xuyangzhong left a comment

Choose a reason for hiding this comment

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

Thanks for driving this. This pr LGTM overall. I just left some minor comments.

Comment thread docs/data/sql_functions.yml
@JinkunLiu JinkunLiu force-pushed the feature/FLINK-37924 branch from d08b908 to 26d8f28 Compare January 26, 2026 15:47
Comment thread docs/data/sql_functions.yml
Comment thread docs/data/sql_functions.yml
@JinkunLiu JinkunLiu requested a review from davidradl January 27, 2026 17:30
Copy link
Copy Markdown
Contributor

@xuyangzhong xuyangzhong left a comment

Choose a reason for hiding this comment

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

Thanks for updating, just one more minor comment.

Copy link
Copy Markdown
Contributor

@xuyangzhong xuyangzhong left a comment

Choose a reason for hiding this comment

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

+1 👍

Copy link
Copy Markdown
Contributor

@yunfengzhou-hub yunfengzhou-hub left a comment

Choose a reason for hiding this comment

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

+1

@yunfengzhou-hub yunfengzhou-hub merged commit 80e26ca into apache:master Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-reviewed PR has been reviewed by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants