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


##########
api/src/test/java/org/apache/iceberg/types/TestTypeUtil.java:
##########
@@ -645,4 +651,77 @@ public void testReassignOrRefreshIdsCaseInsensitive() {
                 required(2, "FIELD2", Types.IntegerType.get())));
     assertThat(actualSchema.asStruct()).isEqualTo(expectedSchema.asStruct());
   }
+
+  private static Stream<Arguments> testTypes() {
+    return Stream.of(
+        Arguments.of(Types.UnknownType.get()),
+        Arguments.of(Types.VariantType.get()),
+        Arguments.of(Types.TimestampNanoType.withoutZone()),
+        Arguments.of(Types.TimestampNanoType.withZone()));
+  }
+
+  @ParameterizedTest
+  @MethodSource("testTypes")
+  public void testAssignFreshIdsWithType(Type testType) {
+    Schema schema =
+        new Schema(required(0, "v", testType), required(1, "A", 
Types.IntegerType.get()));
+    Schema sourceSchema =
+        new Schema(required(1, "v", testType), required(2, "A", 
Types.IntegerType.get()));
+
+    Schema assignedSchema =
+        TypeUtil.assignFreshIds(sourceSchema, new 
AtomicInteger(10)::incrementAndGet);
+    Schema expectedSchema =
+        new Schema(required(11, "v", testType), required(12, "A", 
Types.IntegerType.get()));
+    assertThat(assignedSchema.asStruct()).isEqualTo(expectedSchema.asStruct());
+  }
+
+  @ParameterizedTest
+  @MethodSource("testTypes")
+  public void testReassignIdsWithType(Type testType) {
+    Schema schema =
+        new Schema(required(0, "v", testType), required(1, "A", 
Types.IntegerType.get()));
+    Schema sourceSchema =
+        new Schema(required(1, "v", testType), required(2, "A", 
Types.IntegerType.get()));
+
+    final Schema reassignedSchema = TypeUtil.reassignIds(schema, sourceSchema);
+    assertThat(reassignedSchema.asStruct()).isEqualTo(sourceSchema.asStruct());
+  }
+
+  @ParameterizedTest
+  @MethodSource("testTypes")
+  public void testIndexByIdWithType(Type testType) {
+    Schema schema =

Review Comment:
   This is another case where `schema` isn't used. Could you clean these up? 
The `schema` variable should be used when no `sourceSchema` is needed for ID 
assignment. And we don't need extra variables.



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