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

 ##########
 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:
   Instead of listing types that we don't support, it's probably better to 
check if the type is what we do support.
   
   Also event though Flink is not able to create external table yet, that's 
probably due to the limitation of the DLL and I don't see why we should 
disallow user to modify it.
   
   It seems okay if we say we don't support other types yet.

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