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


##########
core/src/test/java/org/apache/iceberg/TestMetadataTableScansWithPartitionEvolution.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg;
+
+import static org.apache.iceberg.types.Types.NestedField.optional;
+import static org.apache.iceberg.types.Types.NestedField.required;
+
+import java.io.File;
+import java.io.IOException;
+import org.apache.iceberg.io.CloseableIterable;
+import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
+import org.apache.iceberg.relocated.com.google.common.collect.Iterators;
+import org.apache.iceberg.relocated.com.google.common.collect.Streams;
+import org.apache.iceberg.types.Types;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestMetadataTableScansWithPartitionEvolution extends 
MetadataTableScanTestBase {
+  public TestMetadataTableScansWithPartitionEvolution(int formatVersion) {
+    super(formatVersion);
+  }
+
+  @Before
+  public void createTable() throws IOException {
+    TestTables.clearTables();
+    this.tableDir = temp.newFolder();
+    tableDir.delete();
+
+    Schema schema =
+        new Schema(
+            required(1, "id", Types.IntegerType.get()),
+            required(
+                2,
+                "nested",
+                Types.StructType.of(Types.NestedField.required(3, "id", 
Types.IntegerType.get()))));
+    this.metadataDir = new File(tableDir, "metadata");
+    PartitionSpec spec = 
PartitionSpec.builderFor(schema).identity("id").build();
+
+    this.table = create(schema, spec);
+    
table.newFastAppend().appendFile(newDataFile("id=0")).appendFile(newDataFile("id=1")).commit();
+
+    table.updateSpec().addField("nested.id").commit();
+    table
+        .newFastAppend()
+        .appendFile(newDataFile("id=2/nested.id=2"))
+        .appendFile(newDataFile("id=3/nested.id=3"))
+        .commit();
+  }
+
+  @Test
+  public void testManifestsTableWithAddPartitionOnNestedField() throws 
IOException {
+    Table manifestsTable = new ManifestsTable(table.ops(), table);
+    TableScan scan = manifestsTable.newScan();
+
+    try (CloseableIterable<FileScanTask> tasks = scan.planFiles()) {
+      Assert.assertEquals("Should have one tasks", 1, Iterables.size(tasks));

Review Comment:
   nit: I know this is copy/pasted/aligned with the other test, but I think it 
would be better to change those newly added assertions to 
`Assertions.assertThat(tasks).hasSize(1);` and the other one to 
`Assertions.assertThat(Streams.stream(tasks).mapToInt(task -> 
Iterables.size(task.asDataTask().rows()))).hasSize(2);`
   
   Using AssertJ assertions will actually print the content of the iterable if 
the check ever fails, and thus will make debugging much easier. It would be 
great to adjust all of the assertions in this class
   



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