rdblue commented on code in PR #11831:
URL: https://github.com/apache/iceberg/pull/11831#discussion_r1953614605
##########
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);
Review Comment:
Style: avoid `final` for local variables. The only reason to use it is when
the value needs to be passed into a context that requires a `final` reference.
But I'm not sure that's even required anymore because it is almost always
detected automatically.
--
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]