zhangbutao commented on code in PR #4341:
URL: https://github.com/apache/hive/pull/4341#discussion_r1212660411


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java:
##########
@@ -171,6 +172,16 @@ public void 
preCreateTable(org.apache.hadoop.hive.metastore.api.Table hmsTable)
     hmsTable.getParameters().put(BaseMetastoreTableOperations.TABLE_TYPE_PROP,
         BaseMetastoreTableOperations.ICEBERG_TABLE_TYPE_VALUE.toUpperCase());
 
+    // Make sure the created iceberg table location on external warehouse 
location
+    if (Catalogs.hiveCatalog(conf, catalogProperties) && 
hmsTable.getSd().getLocation() == null &&
+        !TableType.EXTERNAL_TABLE.equals(hmsTable.getTableType())) {
+      Map<String, String> params = 
Optional.ofNullable(hmsTable.getParameters()).orElse(Maps.newHashMap());
+      params.put("EXTERNAL", "TRUE");
+      params.put(MetaStoreUtils.EXTERNAL_TABLE_PURGE, "TRUE");
+      hmsTable.setParameters(params);
+      hmsTable.setTableType(TableType.EXTERNAL_TABLE.toString());

Review Comment:
   
http://ci.hive.apache.org/blue/organizations/jenkins/hive-precommit/detail/PR-4341/8/tests/
   Changing the type of the table to `EXTERNAL ` seems to affect the execution 
plan. Not sure why this is happening.
   
   I determine to use a easy workaroud that setting the location to external WH 
location explicitly in `HiveIcebergMetaHook::preCreateTable`:
   



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to