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


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java:
##########
@@ -225,6 +228,20 @@ public void 
preCreateTable(org.apache.hadoop.hive.metastore.api.Table hmsTable)
     setOrcOnlyFilesParam(hmsTable);
   }
 
+  private void 
checkAndSetTblLocation(org.apache.hadoop.hive.metastore.api.Table hmsTable) {
+    try {
+      if (Catalogs.hiveCatalog(conf, catalogProperties) && 
hmsTable.getSd().getLocation() == null) {
+        Warehouse wh = new Warehouse(conf);
+        Path tblPath = wh.getDefaultTablePath(hmsTable.getDbName(), 
hmsTable.getTableName(),
+            
TableType.EXTERNAL_TABLE.toString().equalsIgnoreCase(hmsTable.getTableType()));
+        hmsTable.getSd().setLocation(tblPath.toString());
+        catalogProperties.put(Catalogs.LOCATION, tblPath.toString());

Review Comment:
   I have changed the fix to make sure the table always has correct location no 
matter what's value of `METASTORE_METADATA_TRANSFORMER_CLASS`.  Briefly, This 
change actually simulates the process of setuping the location when creating a 
new table.
   
   
   In current Hive create table process,  If users use the default value of 
`METASTORE_METADATA_TRANSFORMER_CLASS`, the iceberg table will always Externale 
type, and the table location will be determined by this:
   
https://github.com/apache/hive/blob/6aff0d006e81d26cc8dc68dec546eb9650a8e941/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetastoreDefaultTransformer.java#L661-L664
   
   If users disable this conf, the table location will be determined by this:
   
https://github.com/apache/hive/blob/6aff0d006e81d26cc8dc68dec546eb9650a8e941/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java#L2339-L2341
   



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