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_r284872104
 
 

 ##########
 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. Saying in the comment is fine. I meant when we check in the code, it's 
better to check against something we support rather than checking against 
something we don't . The difference is that there might be additional things 
coming in the future that we don't support. We can avoid code changes if we 
don't plan to support it.
   
   2. I understand external table cannot be created in Flink. The reason is the 
limitation of DDL. However, altering an external table should already work. I 
don't see why we need to exclude it now. Let me know if my judgement is 
inaccurate.

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