-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[FLINK-38355][table][FLIP-546] Support CREATE OR ALTER MATERIALIZED TABLE syntax
#27199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
CREATE OR ALTER MATERIALIZED TABLE
CREATE OR ALTER MATERIALIZED TABLECREATE OR ALTER MATERIALIZED TABLE syntax
...l-parser/src/test/java/org/apache/flink/sql/parser/MaterializedTableStatementParserTest.java
Outdated
Show resolved
Hide resolved
...che/flink/table/planner/operations/converters/SqlAlterMaterializedTableAsQueryConverter.java
Outdated
Show resolved
Hide resolved
| .isEqualTo(newTable.getUnresolvedSchema().getPrimaryKey()); | ||
| assertThat(oldTable.getUnresolvedSchema().getWatermarkSpecs()) | ||
| .isEqualTo(newTable.getUnresolvedSchema().getWatermarkSpecs()); | ||
| assertThat(oldTable.getDefinitionQuery()).isNotEqualTo(newTable.getDefinitionQuery()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious what you think, we have removed DefinitionQuery, but we still have DefinitionFreshness. Should we rename DefinitionFreshness so it does not include the word Definition - maybe change just to freshness to simplify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a valid point but we have deprecated the getFreshness() method in CatalogMaterializedTable interface.
...s/src/test/java/org/apache/flink/table/file/testutils/catalog/TestFileSystemCatalogTest.java
Outdated
Show resolved
Hide resolved
...-parser/src/main/java/org/apache/flink/sql/parser/ddl/SqlCreateOrAlterMaterializedTable.java
Outdated
Show resolved
Hide resolved
...l-parser/src/test/java/org/apache/flink/sql/parser/MaterializedTableStatementParserTest.java
Outdated
Show resolved
Hide resolved
.../apache/flink/table/operations/materializedtable/AlterMaterializedTableAsQueryOperation.java
Outdated
Show resolved
Hide resolved
...le-api-java/src/test/java/org/apache/flink/table/catalog/CatalogBaseTableResolutionTest.java
Outdated
Show resolved
Hide resolved
...le-api-java/src/test/java/org/apache/flink/table/catalog/CatalogBaseTableResolutionTest.java
Outdated
Show resolved
Hide resolved
5ba51e6 to
3ad94ba
Compare
3ad94ba to
b08780d
Compare
b08780d to
ba9286e
Compare
What is the purpose of the change
This pull request implements the
CREATE OR ALTER MATERIALIZED TABLEsyntax as proposed in FLIP-546. This new command provides an idempotent way to manage materialized tables, enabling declarative deployment patterns for CI/CD pipelines and infrastructure-as-code workflows.The command intelligently routes to either CREATE or ALTER logic:
CREATE MATERIALIZED TABLE)ALTER MATERIALIZED TABLE AS)This eliminates the need for complex DROP-IF-EXISTS patterns and makes materialized table management more robust and predictable in automated deployment scenarios.
Brief change log
CREATE OR ALTER MATERIALIZED TABLESQL syntax to the Flink SQL parserSqlCreateOrAlterMaterializedTableto handle both create and alter operations based on table existenceSqlCreateOrAlterMaterializedTableConverterfor better encapsulationgetOriginalQuery()method toCatalogMaterializedTableinterface (aligning withCatalogViewinterface)Verifying this change
This change added tests and can be verified as follows:
MaterializedTableStatementParserTestto verify SQL parsing ofCREATE OR ALTERsyntaxSqlMaterializedTableNodeToOperationConverterTest:testCreateOrAlterMaterializedTable()- verifies CREATE behavior when table doesn't existtestCreateOrAlterMaterializedTableForExistingTable()- verifies ALTER behavior when table exists with schema evolutionSqlGatewayRestEndpointMaterializedTableITCaseto validate end-to-end behavior via REST APICREATE OR ALTERstatement multiple timesDoes this pull request potentially affect one of the following parts:
@Public(Evolving): yes -CatalogMaterializedTableinterface extended withgetOriginalQuery()methodDocumentation
docs/content/docs/dev/table/materialized-table/statements.mdexplaining CREATE OR ALTER syntax, behavior, examples, and use cases