hackergin commented on code in PR #25880:
URL: https://github.com/apache/flink/pull/25880#discussion_r1903610990


##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/service/materializedtable/MaterializedTableManager.java:
##########
@@ -804,6 +808,78 @@ protected static String getRefreshStatement(
         return insertStatement.toString();
     }
 
+    private ResultFetcher callAlterMaterializedTableAsQueryOperation(
+            OperationExecutor operationExecutor,
+            OperationHandle handle,
+            AlterMaterializedTableAsQueryOperation op) {
+        ObjectIdentifier tableIdentifier = op.getTableIdentifier();
+        CatalogMaterializedTable materializedTable =
+                getCatalogMaterializedTable(operationExecutor, 
tableIdentifier);
+
+        // 1. suspend the materialized table
+        if (CatalogMaterializedTable.RefreshStatus.SUSPENDED
+                != materializedTable.getRefreshStatus()) {
+            if (CatalogMaterializedTable.RefreshMode.CONTINUOUS
+                    == materializedTable.getRefreshMode()) {
+                suspendContinuousRefreshJob(
+                        operationExecutor, handle, tableIdentifier, 
materializedTable);
+            } else {
+                suspendRefreshWorkflow(
+                        operationExecutor, handle, tableIdentifier, 
materializedTable);
+            }
+        }
+
+        // 2. replace query definition and resume the materialized table
+        // alter materialized table schema
+        operationExecutor.callExecutableOperation(handle, op);
+        ResolvedCatalogMaterializedTable updatedMaterializedTable =
+                getCatalogMaterializedTable(operationExecutor, 
tableIdentifier);
+
+        // 3. resume the materialized table
+        if (CatalogMaterializedTable.RefreshStatus.SUSPENDED
+                != materializedTable.getRefreshStatus()) {

Review Comment:
   The condition here checks the status of the original table. RESUME is needed 
only if the original table’s status is not SUSPENDED.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to