C0urante commented on PR #15893:
URL: https://github.com/apache/kafka/pull/15893#issuecomment-2102926693

   I think this leads to a change in behavior. Right now this test 
(surprisingly!) passes on trunk:
   
   ```java
   public class TimestampConverterTest {
       // ...
   
       @Test
       public void testWithSchemaFieldWithDefaultValue() {
           Map<String, String> config = new HashMap<>();
           config.put(TimestampConverter.TARGET_TYPE_CONFIG, "Timestamp");
           config.put(TimestampConverter.FIELD_CONFIG, "timestamp_field");
           xformValue.configure(config);
   
           java.util.Date defaultFieldValue = new java.util.Date();
           Schema schema = SchemaBuilder.struct()
                   .field(
                           "timestamp_field",
                           Timestamp.builder()
                                   .defaultValue(defaultFieldValue)
                                   .build()
                   );
           Struct value = new Struct(schema)
                   .put("timestamp_field", DATE_PLUS_TIME.getTime());
   
           SourceRecord transformed = 
xformValue.apply(createRecordWithSchema(schema, value));
   
           assertEquals(Schema.Type.STRUCT, transformed.valueSchema().type());
           Struct transformedValue = (Struct) transformed.value();
           assertEquals(DATE_PLUS_TIME.getTime(), 
transformedValue.get("timestamp_field"));
           
assertNull(transformedValue.schema().field("timestamp_field").schema().defaultValue());
       }
   }
   ```
   
   We don't propagate default values for the fields we convert. Instead, we 
automatically substitute in the default value if none is found. This is 
surprising behavior, and has led to things like 
[KIP-581](https://cwiki.apache.org/confluence/display/KAFKA/KIP-581%3A+Value+of+optional+null+field+which+has+default+value)
 and 
[KIP-1040](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=303794677),
 but I don't think we should change it in this KIP because it's out of scope 
and, if necessary, can be touched on in KIP-1040 (which is in discussion at the 
moment).


-- 
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: jira-unsubscr...@kafka.apache.org

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

Reply via email to