Skip to content

[FLINK-40541][table-planner] Detect build-side watermark hidden by column expansion in LATERAL SNAPSHOT - #29081

Closed
fhueske wants to merge 1 commit into
apache:masterfrom
confluentinc:fhueske-FLINK-40541-Detect-build-side-watermark-on-hidden-metadata-column
Closed

[FLINK-40541][table-planner] Detect build-side watermark hidden by column expansion in LATERAL SNAPSHOT#29081
fhueske wants to merge 1 commit into
apache:masterfrom
confluentinc:fhueske-FLINK-40541-Detect-build-side-watermark-on-hidden-metadata-column

Conversation

@fhueske

@fhueske fhueske commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of the change

LATERAL SNAPSHOT detected the build-side watermark by looking for a row-time indicator field in the projected TABLE argument. When the watermark sits on a column that the column-expansion strategy hides from SELECT * (e.g. a virtual metadata column under EXCLUDE_DEFAULT_VIRTUAL_METADATA_COLUMNS), TABLE t expands to a projection that drops the row-time attribute, so the rule found none and wrongly rejected the query with "LATERAL SNAPSHOT requires a watermark on the build-side input".

Recover the row-time attribute from below the hiding projection and re-append it so it reaches the operator: from a WatermarkAssigner, or, when the watermark was pushed into the source, by re-stamping the scan's row-time column (resolved by name from the watermark spec) as a row-time indicator. The top-level Calc projects the re-appended column away, so the output is unchanged.

Brief change log

  • unhide rowtime attributes on the input relation of a SNAPSHOT function call
    • add rowtime attribute to projection of Calc nodes in the subtree of the function input argument
    • fail if no rowtime attribute can be found (like today)
  • add tests to ensure hidden rowtime attributes become available
    • plan-level tests + semantic test

Verifying this change

Run new and existing tests for LateralSnapshotJoin

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? n/a

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

Generated-by: Claude Opus 4.8 (1M context)

…lumn expansion in LATERAL SNAPSHOT

LATERAL SNAPSHOT detected the build-side watermark by looking for a row-time
indicator field in the projected TABLE argument. When the watermark sits on a
column that the column-expansion strategy hides from SELECT * (e.g. a virtual
metadata column under EXCLUDE_DEFAULT_VIRTUAL_METADATA_COLUMNS), TABLE t expands
to a projection that drops the row-time attribute, so the rule found none and
wrongly rejected the query with "LATERAL SNAPSHOT requires a watermark on the
build-side input".

Recover the row-time attribute from below the hiding projection and re-append it
so it reaches the operator: from a WatermarkAssigner, or, when the watermark was
pushed into the source, by re-stamping the scan's row-time column (resolved by
name from the watermark spec) as a row-time indicator. The top-level Calc
projects the re-appended column away, so the output is unchanged.

Co-Generated: Claude Opus 4.8 (1M context)
@flinkbot

flinkbot commented Sep 3, 2026

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

+ "load_completed_time => CAST(TIMESTAMP '2026-07-01 00:00:00' AS TIMESTAMP_LTZ(3))"
+ ") AS s ON probe.pk = s.bk";
final String plan = util.tableEnv().explainSql(sql);
assertThat(plan).contains("LateralSnapshotJoin");

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.

how about verifying the whole plan instead?
e.g. util.verifyRelPlan

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point! Thanks!

@fhueske

fhueske commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Closing this PR, opening one with a different approach

@fhueske fhueske closed this Sep 3, 2026
@fhueske
fhueske deleted the fhueske-FLINK-40541-Detect-build-side-watermark-on-hidden-metadata-column branch September 3, 2026 20:33
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