Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-12694

Specifying a struct-based defaultValue on a SchemaBuilder causes a DataException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Patch Available
    • Major
    • Resolution: Unresolved
    • 2.7.0
    • None
    • connect
    • None

    Description

      When making a call to SchemaBuilder#defaultValue(Object) a DataException will be thrown if the value is of type STRUCT due to a schema mismatch.  This is because the method passes a reference of this, referencing a SchemaBuilder in the ConnectSchema#validate method which later relies on a ConnectSchema#equals equality check which expects the passed schema to be an actual ConnectSchema rather than a SchemaBuilder object that implements Schema.

      Caused by: org.apache.kafka.connect.errors.SchemaBuilderException: Invalid default value
      	at org.apache.kafka.connect.data.SchemaBuilder.defaultValue(SchemaBuilder.java:131)
      	at io.debezium.relational.TableSchemaBuilder.addField(TableSchemaBuilder.java:374)
      	at io.debezium.relational.TableSchemaBuilder.lambda$create$2(TableSchemaBuilder.java:119)
      	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
      	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
      	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
      	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
      	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
      	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
      	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
      	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
      	at io.debezium.relational.TableSchemaBuilder.create(TableSchemaBuilder.java:117)
      	at io.debezium.relational.RelationalDatabaseSchema.buildAndRegisterSchema(RelationalDatabaseSchema.java:130)
      	at io.debezium.connector.oracle.OracleDatabaseSchema.applySchemaChange(OracleDatabaseSchema.java:70)
      	at io.debezium.pipeline.EventDispatcher$SchemaChangeEventReceiver.schemaChangeEvent(EventDispatcher.java:460)
      	at io.debezium.relational.RelationalSnapshotChangeEventSource.lambda$createSchemaChangeEventsForTables$2(RelationalSnapshotChangeEventSource.java:273)
      	... 10 more
      Caused by: org.apache.kafka.connect.errors.DataException: Struct schemas do not match.
      	at org.apache.kafka.connect.data.ConnectSchema.validateValue(ConnectSchema.java:252)
      	at org.apache.kafka.connect.data.ConnectSchema.validateValue(ConnectSchema.java:213)
      	at org.apache.kafka.connect.data.SchemaBuilder.defaultValue(SchemaBuilder.java:129)
      	... 26 more
      

      Attachments

        Issue Links

          Activity

            People

              ChrisEgerton Chris Egerton
              crancran Chris Cranford
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: