dengzhhu653 commented on code in PR #5343:
URL: https://github.com/apache/hive/pull/5343#discussion_r1776714771


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandler.java:
##########
@@ -1101,9 +1101,19 @@ public URI 
getURIForAuth(org.apache.hadoop.hive.metastore.api.Table hmsTable) th
         authURI.append(getPathForAuth(locationProperty.get()))
             .append(encodeString("/metadata/dummy.metadata.json"));
       } else {
-        Table table = IcebergTableUtil.getTable(conf, hmsTable);
-        authURI.append(getPathForAuth(((BaseTable) 
table).operations().current().metadataFileLocation(),
-            hmsTable.getSd().getLocation()));
+        try {
+          Table table = IcebergTableUtil.getTable(conf, hmsTable);
+          authURI.append(getPathForAuth(((BaseTable) 
table).operations().current().metadataFileLocation(),
+                  hmsTable.getSd().getLocation()));
+        } catch (NoSuchTableException ex) {
+          if (hmsTable.getSd() != null && 
!hmsTable.getSd().getLocation().isEmpty()) {
+            
authURI.append(encodeString(URI.create(hmsTable.getSd().getLocation()).getPath()))
+                    .append(encodeString("/metadata/dummy.metadata.json"));
+          } else {
+            throw new URISyntaxException("Couldn't create URI for table: " + 
dbName + "." + tableName,

Review Comment:
   nit: how about changing the error message to `Couldn't create URI for table: 
" + dbName + "." + tableName " + ", as the table location isn't set"`



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