Timm0 commented on code in PR #29968:
URL: https://github.com/apache/flink/pull/29968#discussion_r4597384557


##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/materializedtable/MaterializedTableOperationFactory.java:
##########
@@ -150,12 +150,16 @@ private Operation handleConvert(
                     "Regular table does not support create or alter 
operation.");
         }
 
-        final CatalogMaterializedTable newMaterializedTable =
-                newTableBuilder(declaration, declaration.getMergedSchema())
-                        .refreshStatus(RefreshStatus.INITIALIZING)
-                        .build();
+        if (!oldBaseTable.getPartitionKeys().isEmpty()
+                && 
!oldBaseTable.getPartitionKeys().equals(declaration.getPartitionKeys())) {
+            throw new ValidationException(
+                    String.format(
+                            "The table %s is partitioned, so the conversion 
statement must declare its partition keys in the same order: PARTITIONED BY 
(%s).",

Review Comment:
   Done



##########
docs/content/docs/sql/materialized-table/statements.md:
##########
@@ -267,7 +267,7 @@ See [ALTER MATERIALIZED TABLE AS](#as-select_statement-1) 
for more details.
 
 This lets you adopt a materialized table on top of a table that already 
exists, without dropping and recreating it.
 
-`CREATE OR ALTER MATERIALIZED TABLE` can convert an existing regular table 
into a materialized table in place. The catalog object keeps its identity and 
underlying storage. Its kind becomes materialized table, and its schema, 
options, query definition, freshness, and refresh mode are taken from the 
conversion statement, exactly as for a newly created materialized table. After 
the conversion, a refresh job is launched just as it is for a newly created 
materialized table.
+`CREATE OR ALTER MATERIALIZED TABLE` can convert an existing regular table 
into a materialized table in place. The catalog object keeps its identity and 
underlying storage. Its kind becomes materialized table, and its schema, 
options, query definition, freshness, and refresh mode are taken from the 
conversion statement, exactly as for a newly created materialized table. A 
partitioned table keeps its partition keys. After the conversion, a refresh job 
is launched just as it is for a newly created materialized table.

Review Comment:
   Done



-- 
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