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


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java:
##########
@@ -225,6 +231,38 @@ public void 
preCreateTable(org.apache.hadoop.hive.metastore.api.Table hmsTable)
     setOrcOnlyFilesParam(hmsTable);
   }
 
+  /**
+   * If iceberg table to be created has neither EXTERNAL keyword nor specified 
location, we should firstly
+   * check transform 
MetastoreConf.ConfVars.METASTORE_METADATA_TRANSFORMER_CLASS. If transformer is 
set,
+   * let it determine table's location; otherwise, we should set table's type 
to EXTERNAL to make sure
+   * iceberg table on external location.
+   * @param hmsTable table is to be created
+   */
+  private void 
checkAndSetTblLocation(org.apache.hadoop.hive.metastore.api.Table hmsTable) {
+    HiveMetaStoreClient hmsClient = null;
+    if (Catalogs.hiveCatalog(conf, catalogProperties) && 
hmsTable.getSd().getLocation() == null &&
+        !TableType.EXTERNAL_TABLE.toString().equals(hmsTable.getTableType())) {
+      try {
+        hmsClient = new HiveMetaStoreClient(conf);
+        String transformer =
+            
hmsClient.getMetaConf(MetastoreConf.ConfVars.METASTORE_METADATA_TRANSFORMER_CLASS.getVarname());
+        if (org.apache.commons.lang3.StringUtils.isBlank(transformer)) {
+          Map<String, String> params = 
Optional.ofNullable(hmsTable.getParameters()).orElse(Maps.newHashMap());
+          params.put("EXTERNAL", "TRUE");
+          params.put(MetaStoreUtils.EXTERNAL_TABLE_PURGE, "TRUE");

Review Comment:
   I followed the transformer action:
   
https://github.com/apache/hive/blob/3bc62cbc2d42c22dfd55f78ad7b41ec84a71380f/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetastoreDefaultTransformer.java#L655-L656
   
   Should we be consistent with transformer?



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