You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by "ayushtkn (via GitHub)" <gi...@apache.org> on 2023/05/22 02:55:09 UTC

[GitHub] [hive] ayushtkn commented on a diff in pull request #4341: HIVE-27360: Iceberg: Don't create a new iceberg location if hms table already has a default location

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


##########
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 am not sure if we should in any case allow the table to go to managed warehouse location, rather it should always go to external wh location, iceberg isn't a managed table



##########
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergCreateLocation.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.mr.hive;
+
+import java.io.IOException;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.thrift.TException;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Test;
+
+public class TestHiveIcebergCreateLocation extends HiveIcebergStorageHandlerWithEngineBase {

Review Comment:
   Can adjust the test in an existing class? May be ``TestHiveIcebergStorageHandlerNoScan``?



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org