Skip to content

[FLINK-40111][table] Fall back to retract for a keyless sink without an upsert key - #28704

Merged
twalthr merged 1 commit into
apache:masterfrom
confluentinc:FLINK-40111
Jul 10, 2026
Merged

[FLINK-40111][table] Fall back to retract for a keyless sink without an upsert key#28704
twalthr merged 1 commit into
apache:masterfrom
confluentinc:FLINK-40111

Conversation

@gustavodemorais

Copy link
Copy Markdown
Contributor

What is the purpose of the change

A sink without a primary key that advertises an upsert changelog (ONLY_UPDATE_AFTER) can only apply UPDATE_AFTER when the input carries an upsert key for the downstream to fold by. When the input has no upsert key, the planner now falls back to BEFORE_AND_AFTER so the query plans as retract (when the input can produce UPDATE_BEFORE) instead of emitting an unkeyed upsert stream. Keyed-sink behavior is unchanged.

Brief change log

  • Fall back to retract for a keyless sink whose input has no upsert key in canUpsertKeysWithImmutableColsSatisfyPk.
  • Switch the keyless-union DagOptimizationTest case to a retract sink and regenerate its plan.

Verifying this change

  • ChangelogModeInferenceTest
  • DagOptimizationTest

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)

2.1.196 (Claude Code) with Opus 4.8

…an upsert key

A sink without a primary key that advertises an upsert changelog
(ONLY_UPDATE_AFTER) can only apply UPDATE_AFTER when the input carries an upsert
key for the downstream to fold by. When the input has no upsert key, fall back
to BEFORE_AND_AFTER so the query plans as retract (when the input can produce
UPDATE_BEFORE) instead of emitting an unkeyed upsert stream. Keyed-sink
behavior is unchanged.

Generated-by: Claude Opus 4.8 (Claude Code)
@flinkbot

flinkbot commented Jul 9, 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

@twalthr twalthr left a comment

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.

The change looks good to me. This edge case behavior was undefined before and by looking at the test also untested. The change is a good preparation for developing a more dynamic collect() sink in the future that does not dictate retract but dynamically adjusts to what the upstream pipeline actually demands.

@twalthr
twalthr merged commit 4732a52 into apache:master Jul 10, 2026
@twalthr
twalthr deleted the FLINK-40111 branch July 10, 2026 07:26
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