pvary commented on code in PR #4946:
URL: https://github.com/apache/iceberg/pull/4946#discussion_r896587167


##########
core/src/main/java/org/apache/iceberg/BaseMetastoreTableOperations.java:
##########
@@ -331,9 +331,21 @@ private String newTableMetadataFilePath(TableMetadata 
meta, int newVersion) {
     return metadataFileLocation(meta, String.format("%05d-%s%s", newVersion, 
UUID.randomUUID(), fileExtension));
   }
 
+  /**
+   * Parse the version from table metadata file name.
+   *
+   * @param metadataLocation table metadata file location
+   * @return version of the table metadata file in success case and
+   * -1 if the version is not parsable (as a sign that the metadata is not 
part of this catalog)
+   */
   private static int parseVersion(String metadataLocation) {
     int versionStart = metadataLocation.lastIndexOf('/') + 1; // if '/' isn't 
found, this will be 0
     int versionEnd = metadataLocation.indexOf('-', versionStart);
+    if (versionEnd < 0) {
+      LOG.warn("Found filesystem table's metadata : {}", metadataLocation);

Review Comment:
   The more we talk about this, the less convinced I am that we should 
differentiate between the parsing errors. Nothing really prevents a developer 
to create their own `TableOperations` and using their own metadata filename 
format.
   
   I think it would be good to have a log for the event in any case, at least 
in info level.
   
   Maybe rewrite the whole parsing part to this:
   ```
     private static int parseVersion(String metadataLocation) {
       try {
         int versionStart = metadataLocation.lastIndexOf('/') + 1; // if '/' 
isn't found, this will be 0
         int versionEnd = metadataLocation.indexOf('-', versionStart);
         return Integer.valueOf(metadataLocation.substring(versionStart, 
versionEnd));
       } catch (Throwable e) {
         LOG.info("Unable to parse version from metadata location: {}", 
metadataLocation, e);
         return -1;
       }
     }
   ```
   
   What do you think?



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