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


##########
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:
   > Some output were changing, like the table was managed and now external, I 
think for those we can regenerate the output
   
   @ayushtkn That's not true. I have found out this issue that `EXTERNAL ` 
iceberg table can not use statistics to optimize query, and so the physical 
execution plan was changed. I have filed a PR 
https://github.com/apache/hive/pull/4388, please take a look. Also cc 
@deniskuzZ 



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