Skip to content

[FLINK-40694][table-planner] Fix INSERT INTO with a column list over set-semantic PTFs - #29226

Open
MartijnVisser wants to merge 1 commit into
apache:masterfrom
MartijnVisser:ptf-partial-insert-npe
Open

MartijnVisser wants to merge 1 commit into
apache:masterfrom
MartijnVisser:ptf-partial-insert-npe

Conversation

@MartijnVisser

Copy link
Copy Markdown
Contributor

What is the purpose of the change

  • INSERT INTO t (col list) SELECT ... FROM f(TABLE t PARTITION BY k) failed with must call validate first. PreValidateReWriter validated the source query once to rewrite it, and the planner then validated the same node again with the same validator.

Brief change log

  • PreValidateReWriter only validates the static partitions and the target column list
  • The reordering, NULL padding and static partition constants become a projection on the converted plan, like FLINK-40039 did for CTAS/RTAS
  • Removed SqlRewriterUtils, which has no remaining users

Verifying this change

This change added tests and can be verified as follows:

  • ToChangelogTest and ProcessTableFunctionTest cover the failing statement, four of the new tests fail on master
  • PartialInsertTest covers the behaviour change the commit and the Jira release note record
  • Plan output for a partial insert changed, the golden files are regenerated here

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)

Generated-by: Claude Code (Claude Opus 5)

…set-semantic PTFs

- `PreValidateReWriter` only validates the static partitions and the target column list, it no longer rewrites the source query
- The reordering, NULL padding and static partition constants are applied as a projection on the converted plan, like FLINK-40039 did for CTAS/RTAS
- Remove `SqlRewriterUtils`, which has no remaining users
- An ordinal in `ORDER BY` now refers to the select list of the query, not to the rewritten column order of the sink
- A column that is both a static partition and in the target column list now reports a duplicate target column instead of a column count mismatch
- Plan output for a partial insert that reorders or pads names every field after the sink column, and `INSERT INTO ... PARTITION ... VALUES` keeps the row in the `Values` node

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

flinkbot commented Sep 17, 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

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.

2 participants