nk1506 commented on code in PR #9432: URL: https://github.com/apache/iceberg/pull/9432#discussion_r1445921148
########## hive-metastore/src/main/java/org/apache/iceberg/hive/MetastoreUtil.java: ########## @@ -72,6 +73,23 @@ public static void alterTable( env.putAll(extraEnv); env.put(StatsSetupConst.DO_NOT_UPDATE_STATS, StatsSetupConst.TRUE); - ALTER_TABLE.invoke(client, databaseName, tblName, table, new EnvironmentContext(env)); + try { + ALTER_TABLE.invoke(client, databaseName, tblName, table, new EnvironmentContext(env)); + } catch (RuntimeException e) { Review Comment: Why not unwrap RTE with both `MetaException` as well as `InvalidOperationException` and translate to `org.apache.hadoop.hive.metastore.api.AlreadyExistsException` . Since all the callers of `alterTable` is already handling `org.apache.hadoop.hive.metastore.api.AlreadyExistsException`. I am thinking something like this: ``` catch (RuntimeException e) { // MetaException would be wrapped into RuntimeException during reflection if (e.getCause() instanceof MetaException) { throw (MetaException) e.getCause(); } // InvalidOperationException would be wrapped into RuntimeException during reflection, as // java.lang.RuntimeException:InvalidOperationException(message:new table <> already exists) if (e.getCause() instanceof InvalidOperationException && e.getCause().getMessage() != null && e.getCause() .getMessage() .contains( String.format( "new table %s.%s already exists", table.getDbName(), table.getTableName()))) { throw new AlreadyExistsException( String.format("Table already exists: %s.%s", table.getDbName(), table.getTableName())); } throw e; } ``` -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org