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


##########
core/src/main/java/org/apache/iceberg/view/ViewMetadata.java:
##########
@@ -91,41 +111,325 @@ default ViewMetadata checkAndNormalize() {
         "Unsupported format version: %s",
         formatVersion());
 
-    Preconditions.checkArgument(versions().size() > 0, "Invalid view versions: 
empty");
-    Preconditions.checkArgument(history().size() > 0, "Invalid view history: 
empty");
-    Preconditions.checkArgument(schemas().size() > 0, "Invalid schemas: 
empty");
+    return this;
+  }
 
-    Preconditions.checkArgument(
-        versionsById().containsKey(currentVersionId()),
-        "Cannot find current version %s in view versions: %s",
-        currentVersionId(),
-        versionsById().keySet());
+  static Builder builder() {
+    return new Builder();
+  }
 
-    Preconditions.checkArgument(
-        schemasById().containsKey(currentSchemaId()),
-        "Cannot find current schema with id %s in schemas: %s",
-        currentSchemaId(),
-        schemasById().keySet());
+  static Builder buildFrom(ViewMetadata base) {
+    return new Builder(base);
+  }
+
+  class Builder {
+    private static final int LAST_ADDED = -1;
+    private int formatVersion = DEFAULT_VIEW_FORMAT_VERSION;
+    private String location;
+    private List<Schema> schemas = Lists.newArrayList();
+    private int currentVersionId;
+    private Integer lastAddedVersionId;
+    private Integer lastAddedSchemaId;

Review Comment:
   If these are intended to default to null, it is better to explicitly add 
that default here.



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