snuyanzin commented on code in PR #27488:
URL: https://github.com/apache/flink/pull/27488#discussion_r2741203940


##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/materializedtable/AlterMaterializedTableChangeOperation.java:
##########
@@ -36,30 +78,69 @@
 public class AlterMaterializedTableChangeOperation extends 
AlterMaterializedTableOperation {
 
     private final List<TableChange> tableChanges;
-    private final CatalogMaterializedTable catalogMaterializedTable;
+    private final CatalogMaterializedTable oldTable;
+    private CatalogMaterializedTable materializedTableWithAppliedChanges;
 
     public AlterMaterializedTableChangeOperation(
             ObjectIdentifier tableIdentifier,
             List<TableChange> tableChanges,
+            CatalogMaterializedTable oldTable) {
+        this(tableIdentifier, tableChanges, oldTable, null);
+    }
+
+    private AlterMaterializedTableChangeOperation(
+            ObjectIdentifier tableIdentifier,
+            List<TableChange> tableChanges,
+            CatalogMaterializedTable oldTable,
             CatalogMaterializedTable catalogMaterializedTable) {
         super(tableIdentifier);
         this.tableChanges = tableChanges;
-        this.catalogMaterializedTable = catalogMaterializedTable;
+        this.oldTable = oldTable;
+        this.materializedTableWithAppliedChanges = catalogMaterializedTable;
     }
 
     public List<TableChange> getTableChanges() {
         return tableChanges;
     }
 
-    public CatalogMaterializedTable getCatalogMaterializedTable() {
-        return catalogMaterializedTable;
+    public AlterMaterializedTableChangeOperation copyAsTableChangeOperation() {
+        return new AlterMaterializedTableChangeOperation(
+                tableIdentifier, tableChanges, oldTable, 
materializedTableWithAppliedChanges);
+    }
+
+    public CatalogMaterializedTable getMaterializedTableWithAppliedChanges() {
+        if (oldTable == null) {
+            return materializedTableWithAppliedChanges;
+        }
+
+        MTContext mtContext = new MTContext(oldTable);
+        mtContext.applyTableChanges(tableChanges);
+
+        materializedTableWithAppliedChanges =
+                CatalogMaterializedTable.newBuilder()
+                        .schema(mtContext.retrieveSchema())
+                        .comment(oldTable.getComment())
+                        .partitionKeys(oldTable.getPartitionKeys())
+                        .options(oldTable.getOptions())

Review Comment:
   The only way how partition might be changed is 
   ```sql
   ALTER MATERIALIZED TABLE [catalog_name.][db_name.]table_name REFRESH 
[PARTITION (key1=val1, key2=val2, ...)]
    ```
   and this is handled with completely different operation/converter 
`AlterMaterializedTableRefreshOperation`, 
`SqlAlterMaterializedTableRefreshConverter` and I don't see any specific 
validations there, just conversion to operation
   
   other's change is impossible for no, yes
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to