eric-maynard commented on code in PR #1378:
URL: https://github.com/apache/polaris/pull/1378#discussion_r2047922659


##########
service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java:
##########
@@ -1328,6 +1344,25 @@ public void doCommit(TableMetadata base, TableMetadata 
metadata) {
       String newLocation = writeNewMetadataIfRequired(base == null, metadata);
       String oldLocation = base == null ? null : base.metadataFileLocation();
 
+      // TODO: we should not need to do this hack, but there's no other way to 
modify
+      // metadataFileLocation / currentMetadataLocation
+      if (updateMetadataOnCommit) {
+        try {
+          Field tableMetadataField = 
TableMetadata.class.getDeclaredField("metadataFileLocation");
+          tableMetadataField.setAccessible(true);
+          tableMetadataField.set(metadata, newLocation);

Review Comment:
   For the more philosophical aspect of this comment, I'm not sure if I can 
agree. I'm newer to Iceberg and so I'm unfamiliar with how TableMetadata is 
meant to be handled. 
   
   To me it seems a little odd that we have this field `metadataLocation` which 
never gets set (there is no setter); it seems like the expectation baked in to 
the API is that you'll always read-after-write in order to update the in-memory 
TableMetadata object. In practice, doing this is expensive.
   
   After `commit` is done with a `TableMetadata`, I would expect that the 
`TableMetadata` is updated to reflect the outcome of that commit. That, or it 
could return a new `TableMetadata` -- but we don't have control over that.



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

Reply via email to