bowenli86 commented on a change in pull request #8458: 
[FLINK-12452][table][hive] alterTable() should ensure existing base table and 
the new one are of the same type
URL: https://github.com/apache/flink/pull/8458#discussion_r284882741
 
 

 ##########
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalogBase.java
 ##########
 @@ -318,13 +320,44 @@ public void alterTable(ObjectPath tablePath, 
CatalogBaseTable newCatalogTable, b
                                        throw new 
TableNotExistException(catalogName, tablePath);
                                }
                        } else {
-                               // TODO: [FLINK-12452] alterTable() in all 
catalogs should ensure existing base table and the new one are of the same type
+                               Table oldTable = getHiveTable(tablePath);
+                               TableType oldTableType = 
TableType.valueOf(oldTable.getTableType());
+
+                               // Flink cannot alter existing Hive tables in 
types that Flink cannot create for now,
+                               // including EXTERNAL_TABLE, INDEX_TABLE and 
MATERIALZED_VIEW.
+                               // Note that though Flink cannot create them, 
it's able to read most parts of their metadata,
+                               // like schema and properties, thru existing 
mechanism, but not their unique metadata.
+                               // Also note that add capability of creating 
EXTERNAL_TABLE should be fairly easy to do, e.g. with a table property
+                               // "table_type=external", we just haven't done 
it yet.
+                               // INDEX_TABLE and MATERIALZED_VIEW need more 
research.
+
+                               if (oldTableType == TableType.EXTERNAL_TABLE
 
 Review comment:
   1. I think the current code is better since it checks what we've supported, 
what we plan to support, what we don't know (the "additional things coming in 
the future" you mentioned)
   2. we don't support it yet. external table has additional properties we need 
to parse and check

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to