aturoczy commented on code in PR #4673:
URL: https://github.com/apache/hive/pull/4673#discussion_r1318950652


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandler.java:
##########
@@ -1537,6 +1544,15 @@ public boolean 
shouldOverwrite(org.apache.hadoop.hive.ql.metadata.Table mTable,
     return COPY_ON_WRITE.equalsIgnoreCase(mode);
   }
 
+  @Override
+  public void addResourcesForCreateTable(Map<String, String> tblProps, 
HiveConf hiveConf) {
+    String metadataLocation = 
tblProps.get(BaseMetastoreTableOperations.METADATA_LOCATION_PROP);
+    if (StringUtils.isNotEmpty(metadataLocation)) {

Review Comment:
   Would it not be simpler if the metadataLocation is empty than throw 
exception? 



##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandler.java:
##########
@@ -926,18 +926,25 @@ public URI 
getURIForAuth(org.apache.hadoop.hive.metastore.api.Table hmsTable) th
     StringBuilder authURI =
         new 
StringBuilder(ICEBERG_URI_PREFIX).append(encodeString(dbName)).append("/").append(encodeString(tableName))
             .append("?snapshot=");
-    Optional<String> locationProperty = SessionStateUtil.getProperty(conf, 
hive_metastoreConstants.META_TABLE_LOCATION);
-    if (locationProperty.isPresent()) {
-      Preconditions.checkArgument(locationProperty.get() != null,
-          "Table location is not set in SessionState. Authorization URI cannot 
be supplied.");
-      // this property is set during the create operation before the hive 
table was created
-      // we are returning a dummy iceberg metadata file
-      
authURI.append(encodeString(URI.create(locationProperty.get()).getPath()))
-          .append(encodeString("/metadata/dummy.metadata.json"));
+    // If metadata location is provided we should use that location for auth, 
since during create if the
+    // metadata_location is explicitly provided we register a table using that 
path.
+    Optional<String> metadataLocation =
+        SessionStateUtil.getProperty(conf, 
BaseMetastoreTableOperations.METADATA_LOCATION_PROP);
+    if (metadataLocation.isPresent()) {
+      authURI.append(encodeString(metadataLocation.get()));
     } else {
-      Table table = IcebergTableUtil.getTable(conf, hmsTable);
-      authURI.append(
-          encodeString(URI.create(((BaseTable) 
table).operations().current().metadataFileLocation()).getPath()));
+      Optional<String> locationProperty =
+          SessionStateUtil.getProperty(conf, 
hive_metastoreConstants.META_TABLE_LOCATION);
+      if (locationProperty.isPresent()) {
+        // this property is set during the create operation before the hive 
table was created
+        // we are returning a dummy iceberg metadata file
+        
authURI.append(encodeString(URI.create(locationProperty.get()).getPath()))
+            .append(encodeString("/metadata/dummy.metadata.json"));

Review Comment:
   Why this dummy needs?



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