rdblue commented on code in PR #4716:
URL: https://github.com/apache/iceberg/pull/4716#discussion_r875305790


##########
core/src/main/java/org/apache/iceberg/MetadataUpdateParser.java:
##########
@@ -271,5 +379,55 @@ private static MetadataUpdate readAddSortOrder(JsonNode 
node) {
     UnboundSortOrder sortOrder = SortOrderParser.fromJson(sortOrderNode);
     return new MetadataUpdate.AddSortOrder(sortOrder);
   }
+
+  private static MetadataUpdate readSetDefaultSortOrder(JsonNode node) {
+    int sortOrderId = JsonUtil.getInt(SORT_ORDER_ID, node);
+    return new MetadataUpdate.SetDefaultSortOrder(sortOrderId);
+  }
+
+  // TODO - Return to this when FileIO isn't required.
+  private static MetadataUpdate readAddSnapshot(JsonNode node) {
+    Snapshot snapshot = SnapshotParser.fromJson(null, node);
+    return new MetadataUpdate.AddSnapshot(snapshot);
+  }
+
+  // TODO - Handle the difference between the spec having set semantics and 
the class having single value.
+  private static MetadataUpdate readRemoveSnapshots(JsonNode node) {
+    Set<Long> snapshotIds = JsonUtil.getLongSetOrNull(SNAPSHOT_IDS, node);
+    Preconditions.checkArgument(snapshotIds != null && snapshotIds.size() == 1,
+        "Invalid set of snapshot ids to remove. Expected one value but 
received: %o", snapshotIds);
+    // TODO - Handle the difference between the spec having set semantics and 
the class having single value.
+    Long snapshotId = snapshotIds.iterator().next();
+    return new MetadataUpdate.RemoveSnapshot(snapshotId);
+  }
+
+  private static MetadataUpdate readSetSnapshotRef(JsonNode node) {
+    String refName = JsonUtil.getString(REF_NAME, node);
+    long snapshotId = JsonUtil.getLong(SNAPSHOT_ID, node);
+    SnapshotRefType type = SnapshotRefType.valueOf(JsonUtil.getString(TYPE, 
node).toUpperCase(Locale.ENGLISH));
+    Integer minSnapshotsToKeep = JsonUtil.getIntOrNull(MIN_SNAPSHOTS_TO_KEEP, 
node);
+    Long maxSnapshotAgeMs = JsonUtil.getLongOrNull(MAX_SNAPSHOT_AGE_MS, node);
+    Long maxRefAgeMs = JsonUtil.getLongOrNull(MAX_REF_AGE_MS, node);
+    return new MetadataUpdate.SetSnapshotRef(refName, snapshotId, type, 
minSnapshotsToKeep, maxSnapshotAgeMs, maxRefAgeMs);
+  }
+
+  private static MetadataUpdate readSetProperties(JsonNode node) {
+    // TODO - Instead of this we could just call removeProperties, which would 
avoid the need for null fields.
+    //   but that's probably not intuitive for the user.
+    Map<String, String> updated = JsonUtil.getStringMapWithNullValues(UPDATED, 
node);
+    return new MetadataUpdate.SetProperties(updated);
+  }

Review Comment:
   Ah, I think the right way to remove properties at this level is to use the 
`RemovePropertiesUpdate` from the spec.
   
   Otherwise, this is ambiguous because someone may be trying to set a property 
to null, instead of removing it. That's what I thought you were trying to 
support with my comment above. But I don't think that we allow setting 
properties to null.



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