pvary commented on a change in pull request #1495:
URL: https://github.com/apache/iceberg/pull/1495#discussion_r497046168



##########
File path: 
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java
##########
@@ -142,16 +146,22 @@ protected void doCommit(TableMetadata base, TableMetadata 
metadata) {
     String newMetadataLocation = writeNewMetadata(metadata, currentVersion() + 
1);
 
     boolean threw = true;
+    boolean updateHiveTable = false;
     Optional<Long> lockId = Optional.empty();
     try {
       lockId = Optional.of(acquireLock());
       // TODO add lock heart beating for cases where default lock timeout is 
too low.
       Table tbl;
-      if (base != null) {
-        LOG.debug("Committing existing table: {}", fullName);
+      try {
         tbl = metaClients.run(client -> client.getTable(database, tableName));
+        if (base == null && tbl.getParameters().get(TABLE_CREATION_FROM_HIVE) 
== null) {
+          throw new AlreadyExistsException("Table already exists: %s.%s", 
database, tableName);
+        }
+        updateHiveTable = true;
+        LOG.debug("Committing existing table: {}", fullName);
         tbl.setSd(storageDescriptor(metadata)); // set to pickup any schema 
changes
-      } else {
+      } catch (NoSuchObjectException nte) {
+        LOG.trace("Table not found {}", fullName, nte);

Review comment:
       Can we suppress the warning instead?
   ```
   > Task :iceberg-hive-metastore:compileJava
   
/Users/petervary/dev/upstream/iceberg/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java:163:
 error: [CatchBlockLogException] Catch block contains log statements but thrown 
exception is never logged.
         } catch (NoSuchObjectException nte) {
           ^
       (see 
https://github.com/palantir/gradle-baseline#baseline-error-prone-checks)
     Did you mean 'LOG.debug("Committing new table: {}", fullName, nte);'?
   ```
   Or we should just log the exception on debug level?
   I wanted to dig the exception as deep as possible, as it is normal to have 
it 😄 




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

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