Skip to content

[FLINK-39268][table] Expand and reuse local refs in CalcCodeGenerator#28113

Open
snuyanzin wants to merge 5 commits intoapache:masterfrom
snuyanzin:flink39268
Open

[FLINK-39268][table] Expand and reuse local refs in CalcCodeGenerator#28113
snuyanzin wants to merge 5 commits intoapache:masterfrom
snuyanzin:flink39268

Conversation

@snuyanzin
Copy link
Copy Markdown
Contributor

What is the purpose of the change

The PR makes local refs expandable and reusable (so far projections and filters)
Also since for some operators like AND, OR, CASE, COALESCE there might be short circuits
it introduces scope

also deterministic/non-deterministic functions are taken into account

Brief change log

code gen

Verifying this change

existing tests and a number of added tests

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)

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)

@flinkbot
Copy link
Copy Markdown
Collaborator

flinkbot commented May 4, 2026

CI report:

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

Copy link
Copy Markdown
Contributor

@twalthr twalthr 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 @snuyanzin. This will improve all Flink SQL pipelines significantly. I added some feedback around code readability and maintenance.

"[{\"k\":\"V\"}]",
STRING().notNull(),
STRING().notNull())),
// Shared JSON(f) inside two JSON_ARRAY projections.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

inside two JSON_ARRAY projections

I see only one projection. I guess you are assuming two due to internals of the test base that combines Table API and SQL into one? Maybe it makes sense to have a test that fully uses SQL to explicitly test two JSON_ARRAY projections

/**
* Pins the CASE-WHEN guard interaction with the RexLocalRef cache.
*
* <p>Prior to scoped caching, RexProgramBuilder collapsed the division {@code a / b} into a
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Prior to scoped caching,

Please instruct AI to not use temporal references. Something like:

- Add comments that are useful for long-term maintenance of the code base. Avoid obvious JavaDocs, obvious parameter or return type descriptions. Don't include short-term comments that have been directly derived from the prompt such as "now uses" or "now works differently" or historical references like "previously", those rather distract a reader who is new to the code base.

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