Skip to content

[FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion#28163

Merged
snuyanzin merged 7 commits into
apache:masterfrom
raminqaf:FLINK-39662
May 19, 2026
Merged

[FLINK-39662][table] Support ALTER MATERIALIZED TABLE ... SET (...) conversion#28163
snuyanzin merged 7 commits into
apache:masterfrom
raminqaf:FLINK-39662

Conversation

@raminqaf
Copy link
Copy Markdown
Contributor

What is the purpose of the change

The parser already accepted ALTER MATERIALIZED TABLE t SET ('k' = 'v'), but the planner had no converter registered for SqlAlterMaterializedTableOptions. As a result, the statement was rejected at plan time with TableException: Unsupported query.

Add SqlAlterMaterializedTableOptionsConverter and register it in SqlNodeConverters#registerMaterializedTableConverters. The converter emits an AlterMaterializedTableChangeOperation with one TableChange.set(key, value) per option provided. Merge with existing options is handled by MaterializedTableChangeHandler.setTableOption, which mirrors the create-or-alter path established in FLINK-39199.

Planner-level tests cover the success path, single-option summary string, unknown table, and applying SET to a regular table. A gateway IT test exercises the end-to-end flow in FULL refresh mode where the change is applied directly to the catalog. The user-facing docs are updated for the new SET clause.

Brief change log

  • Add SqlAlterMaterializedTableOptionsConverter
  • register the new converter in SqlNodeConverters#registerMaterializedTableConverters
  • Planner-level tests

Verifying this change

  • Added test in planner-level under SqlMaterializedTableNodeToOperationConverterTest.java
  • Added IT cases in MaterializedTableStatementITCase.java

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? (yes)
  • If yes, how is the feature documented? (docs)

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

Generated-by: Opus 4.7

@flinkbot
Copy link
Copy Markdown
Collaborator

flinkbot commented May 15, 2026

CI report:

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

@raminqaf
Copy link
Copy Markdown
Contributor Author

@flinkbot run azure

Comment thread docs/content/docs/sql/materialized-table/statements.md
@snuyanzin
Copy link
Copy Markdown
Contributor

LGTM
let's wait for ci

raminqaf and others added 5 commits May 18, 2026 17:44
…onversion

The parser already accepted `ALTER MATERIALIZED TABLE t SET ('k' = 'v')`, but the planner had no converter registered for `SqlAlterMaterializedTableOptions`. As a result, the statement was rejected at plan time with `TableException: Unsupported query`.

Add `SqlAlterMaterializedTableOptionsConverter` and register it in `SqlNodeConverters#registerMaterializedTableConverters`. The converter emits an `AlterMaterializedTableChangeOperation` with one `TableChange.set(key, value)` per option provided. Merge with existing options is handled by `MaterializedTableChangeHandler.setTableOption`, which mirrors the create-or-alter path established in FLINK-39199.

Planner-level tests cover the success path, single-option summary string, unknown table, and applying SET to a regular table. A gateway IT test exercises the end-to-end flow in FULL refresh mode where the change is applied directly to the catalog. The user-facing docs are updated for the new SET clause.
Spell out the behavior for duplicate keys (last value wins, applied in statement order) and the empty option list (rejected). Add a corresponding example.

AlterMaterializedTableChangeOperation op =
(AlterMaterializedTableChangeOperation) operation;
assertThat(op.getTableIdentifier().toString()).isEqualTo("`builtin`.`default`.`base_mtbl`");
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.

Suggested change
assertThat(op.getTableIdentifier().toString()).isEqualTo("`builtin`.`default`.`base_mtbl`");
assertThat(op.getTableIdentifier()).hasToString("`builtin`.`default`.`base_mtbl`");

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.

Addressed and updated it in the other tests too

@snuyanzin snuyanzin merged commit 9a72fde into apache:master May 19, 2026
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