Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-1077

Integer default value for DECIMAL column fails with Avro Converter

    Details

      Description

      Consider a table like this:

      CREATE TABLE some_table (
            id INT AUTO_INCREMENT NOT NULL,
            my_col DECIMAL(4,0) DEFAULT 42,
            PRIMARY KEY (id)
      ) DEFAULT CHARSET=utf8;
      

      This causes the Avro converter to fail due to the integer default value:

      org.apache.kafka.connect.errors.SchemaBuilderException: Invalid default value
      	at org.apache.kafka.connect.data.SchemaBuilder.defaultValue(SchemaBuilder.java:131)
      	at io.confluent.connect.avro.AvroData.toConnectSchema(AvroData.java:1562)
      	at io.confluent.connect.avro.AvroData.toConnectSchema(AvroData.java:1467)
      	at io.confluent.connect.avro.AvroData.toConnectSchema(AvroData.java:1443)
      	at io.confluent.connect.avro.AvroData.toConnectSchema(AvroData.java:1467)
      	at io.confluent.connect.avro.AvroData.toConnectSchema(AvroData.java:1443)
      	at io.confluent.connect.avro.AvroData.toConnectSchema(AvroData.java:1323)
      	at io.confluent.connect.avro.AvroData.toConnectData(AvroData.java:1047)
      	at io.confluent.connect.avro.AvroConverter.toConnectData(AvroConverter.java:89)
      	at io.debezium.data.VerifyRecord.isValid(VerifyRecord.java:726)
      	at io.debezium.embedded.AbstractConnectorTest.validate(AbstractConnectorTest.java:621)
      	at java.util.ArrayList.forEach(ArrayList.java:1257)
      	at io.debezium.embedded.AbstractConnectorTest$SourceRecords.forEach(AbstractConnectorTest.java:465)
      	at io.debezium.connector.mysql.MySqlFixedLengthBinaryColumnIT.shouldConsumeAllEventsFromDatabaseUsingBinlogAndNoSnapshot(MySqlFixedLengthBinaryColumnIT.java:103)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
      	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
      Caused by: org.apache.kafka.connect.errors.DataException: Invalid Java object for schema type BYTES: class [B for field: "null"
      	at org.apache.kafka.connect.data.ConnectSchema.validateValue(ConnectSchema.java:240)
      	at org.apache.kafka.connect.data.ConnectSchema.validateValue(ConnectSchema.java:213)
      	at org.apache.kafka.connect.data.SchemaBuilder.defaultValue(SchemaBuilder.java:129)
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  jpechanec Jiri Pechanec
                  Reporter:
                  gunnar.morling Gunnar Morling
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: