nastra commented on code in PR #12401:
URL: https://github.com/apache/iceberg/pull/12401#discussion_r1973802271


##########
core/src/test/java/org/apache/iceberg/view/TestViewMetadata.java:
##########
@@ -396,6 +397,28 @@ public void viewVersionHistoryIsCorrectlyRetained() {
         .hasMessage("Cannot set current version to unknown version: 1");
   }
 
+  @Test
+  public void versionsAddedInCurrentBuildAreRetained() {
+    ViewVersion v1 = newViewVersion(1, "select 1 as count");
+    ViewVersion v2 = newViewVersion(2, "select count from t1");
+    ViewVersion v3 = newViewVersion(3, "select count(1) as count from t2");
+
+    ViewMetadata metadata =
+        ViewMetadata.builder()
+            .setLocation("location")
+            .addSchema(new Schema(Types.NestedField.required(1, "x", 
Types.LongType.get())))
+            .addVersion(v1)
+            .setCurrentVersionId(v1.versionId())
+            
.setProperties(ImmutableMap.of(ViewProperties.VERSION_HISTORY_SIZE, "2"))
+            .build();
+    assertThat(metadata.versions()).containsOnly(v1);
+
+    ViewMetadata updated = 
ViewMetadata.buildFrom(metadata).addVersion(v2).addVersion(v3).build();
+    assertThat(updated.versions()).containsExactlyInAnyOrder(v1, v2, v3);
+    updated = ViewMetadata.buildFrom(updated).build();

Review Comment:
   please add `// rebuild the metadata to expire older versions` right above 
this line



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to