laskoviymishka commented on code in PR #17653:
URL: https://github.com/apache/iceberg/pull/17653#discussion_r4241986244


##########
kafka-connect/kafka-connect/src/test/java/org/apache/iceberg/connect/data/TestRecordConverter.java:
##########
@@ -962,6 +988,130 @@ public void testNoSchemaEvolutionStructWithNullValue() {
     assertThat(consumer.empty()).isTrue();
   }
 
+  @ParameterizedTest
+  @ValueSource(booleans = {true, false})
+  public void testNoSchemaEvolutionStructWithNullValueOfFieldWithDefault(
+      boolean replaceNullWithDefault) {
+    when(config.replaceNullWithDefault()).thenReturn(replaceNullWithDefault);
+
+    org.apache.iceberg.Schema nestedStructSchema =
+        new org.apache.iceberg.Schema(
+            NestedField.required(1, "id", IntegerType.get()),
+            NestedField.optional(
+                2, "nested", StructType.of(NestedField.optional(3, "a", 
IntegerType.get()))));
+
+    Table table = mock(Table.class);
+    when(table.schema()).thenReturn(nestedStructSchema);
+    RecordConverter converter = new RecordConverter(table, config);
+
+    SchemaBuilder connectNestedSchemaBuilder =
+        SchemaBuilder.struct().optional().field("a", 
Schema.OPTIONAL_INT32_SCHEMA);
+    Struct nestedDefault = new Struct(connectNestedSchemaBuilder).put("a", 42);

Review Comment:
   Since building the struct from the builder is the required workaround and 
not an accident, I'd add a one-line comment pointing at KAFKA-12694, so the 
next person doesn't try the "obvious" fix and hit `Struct schemas do not 
match`. Same in 
`testNestedSchemaEvolutionStructWithNullValueOfFieldWithDefault`. Not blocking.



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