stevenzwu opened a new issue #1513:
URL: https://github.com/apache/iceberg/issues/1513


   `TableOperations#current()` can return null `TableMetadata`. E.g. 
`BaseMetastoreTableOperations` returns null with `NoSuchTableException`. 
   
   ```
     @Override
     public TableMetadata current() {
       if (shouldRefresh) {
         return refresh();
       }
       return currentMetadata;
     }
   
     @Override
     public TableMetadata refresh() {
       boolean currentMetadataWasAvailable = currentMetadata != null;
       try {
         doRefresh();
       } catch (NoSuchTableException e) {
         if (currentMetadataWasAvailable) {
           LOG.warn("Could not find the table during refresh, setting current 
metadata to null", e);
         }
   
         currentMetadata = null;
         currentMetadataLocation = null;
         version = -1;
         shouldRefresh = false;
         throw e;
       }
       return current();
     }
   ```
   
   Caller handles the null in inconsistent way. Maybe a few callers do the null 
check, like `BaseMetastoreCatalog`. Most callers (like 
`MergingSnapshotProducer`) don't check and can throw unfriendly NPE in this 
case. 
   ```
   java.lang.NullPointerException
           at 
org.apache.iceberg.MergingSnapshotProducer.<init>(MergingSnapshotProducer.java:81)
           at org.apache.iceberg.MergeAppend.<init>(MergeAppend.java:32)
           at 
org.apache.iceberg.BaseTransaction.newAppend(BaseTransaction.java:124)
   ```
   
   Should `TableOperations#current()` just throw more friendly 
`NoSuchTableException` instead?


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