szehon-ho commented on a change in pull request #4261:
URL: https://github.com/apache/iceberg/pull/4261#discussion_r819126363



##########
File path: 
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java
##########
@@ -271,29 +273,32 @@ protected void doCommit(TableMetadata base, TableMetadata 
metadata) {
       try {
         persistTable(tbl, updateHiveTable);
         commitStatus = CommitStatus.SUCCESS;
-      } catch (Throwable persistFailure) {
+      } catch (org.apache.hadoop.hive.metastore.api.AlreadyExistsException e) {
+        throw new AlreadyExistsException(e, "Table already exists: %s.%s", 
database, tableName);
+
+      } catch (InvalidObjectException e) {
+        throw new ValidationException(e, "Invalid table name for %s.%s", 
database, tableName);

Review comment:
       So I'll try to explain the HMS flow (using the latest Hive release tag 
github links to make it persistent):
   
   Every call goes through HMSHandler.  For these two calls (CreateTable or 
AlterTable), it goes like:
   
   
[HMSHandler::create_table_core](https://github.com/apache/hive/blob/8190d2be7b7165effa62bd21b7d60ef81fb0e4af/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java#L1789)
 -> 
[ObjectStore::createTable](https://github.com/apache/hive/blob/8190d2be7b7165effa62bd21b7d60ef81fb0e4af/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java#L1298),
 the call being at this line : ms.createTable()
   
   
[HMSHandler::alter_table_core](https://github.com/apache/hive/blob/8190d2be7b7165effa62bd21b7d60ef81fb0e4af/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java#L4998)
 -> 
[ObjectStore::alterTable](https://github.com/apache/hive/blob/8190d2be7b7165effa62bd21b7d60ef81fb0e4af/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java#L4005)
 , the call being at the line ms.alterTable()
   
   After this it uses JDO persistence library which does not throw any 
InvalidObjectException.
   
   So we check the four places.  InvalidObjectException is only ever thrown in 
the first one (HMSHandler::create_table_core).  
   
   Note that ObjectStore methods do call convertToMTable() that does throw the 
InvalidObjectException if database is null, but in Iceberg case this is 
actually checked way before it gets here (can share the stack trace if you 
want).
   
   Not sure if this helps?




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