-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[FLINK-36994][table] Support ALTER MATERIALIZED TABLE As <Query> statement #25880
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
Conversation
f2205e0
to
9e31130
Compare
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.
@hackergin Thanks for your contribution, I left some comments.
...link-table-common/src/main/java/org/apache/flink/table/catalog/CatalogMaterializedTable.java
Outdated
Show resolved
Hide resolved
.../apache/flink/table/operations/materializedtable/AlterMaterializedTableAsQueryOperation.java
Outdated
Show resolved
Hide resolved
.../apache/flink/table/operations/materializedtable/AlterMaterializedTableAsQueryOperation.java
Outdated
Show resolved
Hide resolved
.../apache/flink/table/operations/materializedtable/AlterMaterializedTableAsQueryOperation.java
Outdated
Show resolved
Hide resolved
.../apache/flink/table/operations/materializedtable/AlterMaterializedTableAsQueryOperation.java
Outdated
Show resolved
Hide resolved
.../java/org/apache/flink/table/gateway/service/materializedtable/MaterializedTableManager.java
Outdated
Show resolved
Hide resolved
.../java/org/apache/flink/table/gateway/service/materializedtable/MaterializedTableManager.java
Show resolved
Hide resolved
.../apache/flink/table/planner/operations/SqlMaterializedTableNodeToOperationConverterTest.java
Outdated
Show resolved
Hide resolved
...y/src/test/java/org/apache/flink/table/gateway/service/MaterializedTableStatementITCase.java
Outdated
Show resolved
Hide resolved
...y/src/test/java/org/apache/flink/table/gateway/service/MaterializedTableStatementITCase.java
Outdated
Show resolved
Hide resolved
.../apache/flink/table/operations/materializedtable/AlterMaterializedTableAsQueryOperation.java
Outdated
Show resolved
Hide resolved
} | ||
} | ||
for (int i = oldSchema.getColumns().size(); i < newSchema.getColumns().size(); i++) { | ||
Column newColumn = newSchema.getColumns().get(i); |
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.
If the new added column is duplicated with old column, what behavior is? I think you should a test case to verify it.
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.
Based on my testing, if duplicate field names appear in a query, the latter field names will automatically have suffixes added, which seems consistent with the logic of the Calcite framework. For example, if there are two fields named a
, the second a will automatically be renamed to a0
.
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 checked the implementation of CreateView, and it does include validation for field name conflicts. We can reuse this logic.
Line 144 in 75c26e8
private static void validateDuplicatedColumnNames( |
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.
Can you help create a jira issue to track it? I think we should forbid the duplicated name case.
9e31130
to
9a19d23
Compare
90c372c
to
a204971
Compare
a204971
to
480c394
Compare
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.
Thanks for updating, I left some comments.
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/TableChange.java
Outdated
Show resolved
Hide resolved
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/TableChange.java
Show resolved
Hide resolved
.../apache/flink/table/operations/materializedtable/AlterMaterializedTableAsQueryOperation.java
Outdated
Show resolved
Hide resolved
.../apache/flink/table/operations/materializedtable/AlterMaterializedTableAsQueryOperation.java
Outdated
Show resolved
Hide resolved
.../apache/flink/table/operations/materializedtable/AlterMaterializedTableAsQueryOperation.java
Outdated
Show resolved
Hide resolved
.../java/org/apache/flink/table/gateway/service/materializedtable/MaterializedTableManager.java
Show resolved
Hide resolved
...y/src/test/java/org/apache/flink/table/gateway/service/MaterializedTableStatementITCase.java
Outdated
Show resolved
Hide resolved
...y/src/test/java/org/apache/flink/table/gateway/service/MaterializedTableStatementITCase.java
Outdated
Show resolved
Hide resolved
...y/src/test/java/org/apache/flink/table/gateway/service/MaterializedTableStatementITCase.java
Outdated
Show resolved
Hide resolved
...y/src/test/java/org/apache/flink/table/gateway/service/MaterializedTableStatementITCase.java
Outdated
Show resolved
Hide resolved
e11351a
to
74b9f83
Compare
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.
@hackergin Thanks for updating, LGTM overall, just left some minor comments. BTW, can you help rebase the master branch?
...che/flink/table/planner/operations/converters/SqlAlterMaterializedTableAsQueryConverter.java
Outdated
Show resolved
Hide resolved
...g/apache/flink/table/operations/materializedtable/AlterMaterializedTableChangeOperation.java
Outdated
Show resolved
Hide resolved
...che/flink/table/planner/operations/converters/SqlAlterMaterializedTableAsQueryConverter.java
Outdated
Show resolved
Hide resolved
.../apache/flink/table/planner/operations/SqlMaterializedTableNodeToOperationConverterTest.java
Show resolved
Hide resolved
.../java/org/apache/flink/table/gateway/service/materializedtable/MaterializedTableManager.java
Show resolved
Hide resolved
.../java/org/apache/flink/table/gateway/service/materializedtable/MaterializedTableManager.java
Show resolved
Hide resolved
74b9f83
to
7ed0158
Compare
.../java/org/apache/flink/table/gateway/service/materializedtable/MaterializedTableManager.java
Outdated
Show resolved
Hide resolved
|
||
throw new SqlExecutionException( | ||
String.format( | ||
"Failed to alter materialized table as query operation for materialized table %s.", |
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.
"Failed to alter materialized table as query operation for materialized table %s.", | |
"Failed to restore the continuous refresh job using original query {} when altering materialized table {} select query failure.", |
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.
Here, I understand that it’s not about resuming the failure of the original task, but rather failing to start with a new query, keeping it consistent with the above log.warn()
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.
BTW, I think we can print the log only before throw the exception, it makes me a mistake.
7ed0158
to
5214def
Compare
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.
LGTM
What is the purpose of the change
Add support query modification for materialized table
Brief change log
**
Verifying this change
Some unit test and ITCase will be added in MaterializedTableStatementITCase to verify these changes.
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (no)Documentation