You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/08/09 08:04:07 UTC

[GitHub] [kafka] gunnarmorling edited a comment on pull request #10566: KAFKA-12694 Avoid schema mismatch DataException when validating default values

gunnarmorling edited a comment on pull request #10566:
URL: https://github.com/apache/kafka/pull/10566#issuecomment-895027031


   Hey @C0urante,
   
   ```
   Struct defaultValue = new Struct(builder);
   ```
   
   Initializing a `Struct` with a builder rather than a `Schema` seems to be an odd thing to do, no? Here's an example for triggering the exception we ran into, without the proposed change:
   
   ```java
   SchemaBuilder builder = SchemaBuilder.struct()
       .field("f1", Schema.BOOLEAN_SCHEMA);
   
   Struct defaultValue = new Struct(builder.build()); // the Struct receives a schema, not a builder
   defaultValue.put("f1", true);
   
   builder.defaultValue(defaultValue)
        .build();
   ```
   
   I think ultimately this exposes sort of a gap in the KC schema API, as there's a recursive relationship between struct and schema in the default value case. The suggested change should improve the situation though for the IMO more common case where a `Struct` is initialized with a `Schema` rather than a `SchemaBuilder`.
   
   @C0urante, @rhauch, any thoughts?


-- 
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-unsubscribe@kafka.apache.org

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