Skip to content

[FLINK-39548][table-planner] Fix projected primary key indices for ch…#28042

Open
ljw-hit wants to merge 2 commits intoapache:masterfrom
ljw-hit:fix-source-scan-output-type
Open

[FLINK-39548][table-planner] Fix projected primary key indices for ch…#28042
ljw-hit wants to merge 2 commits intoapache:masterfrom
ljw-hit:fix-source-scan-output-type

Conversation

@ljw-hit
Copy link
Copy Markdown

@ljw-hit ljw-hit commented Apr 27, 2026

What is the purpose of the change

Fix primary key index derivation for changelog sources when the scan output is projected.

CommonExecTableSourceScan previously derived primary key field indices from the physical row type, which can differ from the projected output type (e.g., after reordering / projection). This could misalign the partitioner/key selector with the declared primary key fields. This PR derives indices from the projected output type instead.

Brief change log

  • Derive primary key indices from the projected output type for changelog sources.
  • Add a regression test covering primary key extraction with projected/reordered output.
  • Remove the now-unused physical row type helper.

Verifying this change

This change added tests and can be verified as follows:

  • ./mvnw -pl flink-table/flink-table-planner -Dtest=TransformationsTest test

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 (TraeCli / GPT-5.4)

Generated-by: TraeCli (GPT-5.4)

…angelog sources

This fixes CommonExecTableSourceScan to derive primary key indices from the
projected output type instead of the physical row type. Queries that reorder
projected columns for changelog sources now keep the source partitioner aligned
with the declared primary key fields.

The change also adds a regression test that validates the partitioner extracts
keys from the projected row in the expected primary key order.

Generated-by: TraeCli (GPT-5.4)
@flinkbot
Copy link
Copy Markdown
Collaborator

flinkbot commented Apr 27, 2026

CI report:

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

@spuru9
Copy link
Copy Markdown
Contributor

spuru9 commented Apr 28, 2026

@ljw-hit Can you update the PR description to follow the guidelines and add more details about the change.

@github-actions github-actions Bot added the community-reviewed PR has been reviewed by the community. label Apr 28, 2026
The helper became unused after deriving PK indices from the projected output type.
@ljw-hit
Copy link
Copy Markdown
Author

ljw-hit commented Apr 29, 2026

Thanks for spotting this. getPhysicalRowType(ResolvedSchema) became unused after switching PK index derivation to the projected output type, and it has been removed in commit 7367645.

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.

3 participants