kbendick commented on code in PR #4594:
URL: https://github.com/apache/iceberg/pull/4594#discussion_r855396589


##########
nessie/src/main/java/org/apache/iceberg/nessie/NessieTableOperations.java:
##########
@@ -75,21 +87,27 @@ protected String tableName() {
     return key.toString();
   }
 
-  @Override
-  protected void refreshFromMetadataLocation(String newLocation, 
Predicate<Exception> shouldRetry, int numRetries) {
-    super.refreshFromMetadataLocation(newLocation, shouldRetry, numRetries, 
this::loadTableMetadata);
-  }
-
-  private TableMetadata loadTableMetadata(String metadataLocation) {
+  private TableMetadata loadTableMetadata(String metadataLocation, Reference 
reference) {
     // Update the TableMetadata with the Content of NessieTableState.
-    TableMetadata.Builder builder = 
TableMetadata.buildFrom(TableMetadataParser.read(io(), metadataLocation))
+    TableMetadata deserialized;
+    if (table.getMetadata() != null) {
+      deserialized = TableMetadataParser.fromJson(io(), metadataLocation, 
table.getMetadata().getMetadata());
+    } else {
+      deserialized = TableMetadataParser.read(io(), metadataLocation);
+    }
+    Map<String, String> newProperties = 
Maps.newHashMap(deserialized.properties());
+    newProperties.put(NESSIE_COMMIT_ID_PROPERTY, reference.getHash());
+    TableMetadata.Builder builder = TableMetadata.buildFrom(deserialized, true)
         .setCurrentSchema(table.getSchemaId())
         .setDefaultSortOrder(table.getSortOrderId())
         .setDefaultPartitionSpec(table.getSpecId())
-        .withMetadataLocation(metadataLocation);
+        .withMetadataLocation(metadataLocation)

Review Comment:
   I think you don't need to pass `true` in here. If `base` doesn't have that 
field set, it will just be null. Otherwise it will get overridden after this 
builder is called with `.build()`.



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