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

TinyIntOneToBooleanConverter doesn't seem to work with columns having a default value.

    Details

      Description

      The MySQL table has a couple of columns defined as BOOLEAN with a default value set as 0(false).

        `is_claimed` BOOLEAN NOT NULL DEFAULT 0,
        `is_completed` BOOLEAN NOT NULL DEFAULT 0
      

      As highlighted in the documentation, https://debezium.io/documentation/reference/1.1/connectors/mysql.html#_boolean_values
      BOOLEAN is an alias for TINYINT(1) in MySQL, we wanted to use the TinyIntOneToBooleanConverter on the boolean columns as suggested.

      On enabling the above converter for these 2 columns, we see an error which says:

      org.apache.kafka.connect.errors.DataException: Invalid Java object for schema type BOOLEAN: class java.lang.Short for field: \"null\"
      

      It seems like if a default value is set for the above TINYINT(1) column, the type of the default value is short and hence fails the validation here.

      https://github.com/debezium/debezium/blob/v1.1.0.Final/debezium-core/src/main/java/io/debezium/relational/TableSchemaBuilder.java#L378-L381

      Stack trace:

      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:380)
      	at io.debezium.relational.TableSchemaBuilder.lambda$create$2(TableSchemaBuilder.java:120)
      	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
      	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
      	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
      	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
      	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
      	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
      	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
      	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
      	at io.debezium.relational.TableSchemaBuilder.create(TableSchemaBuilder.java:118)
      	at io.debezium.relational.RelationalDatabaseSchema.buildAndRegisterSchema(RelationalDatabaseSchema.java:131)
      	at io.debezium.connector.mysql.MySqlSchema.lambda$refreshSchemas$2(MySqlSchema.java:279)
      	at java.util.concurrent.ConcurrentHashMap$KeySetView.forEach(ConcurrentHashMap.java:4649)
      	at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1080)
      	at io.debezium.connector.mysql.MySqlSchema.refreshSchemas(MySqlSchema.java:277)
      	at io.debezium.connector.mysql.MySqlSchema.loadHistory(MySqlSchema.java:254)
      	at io.debezium.connector.mysql.MySqlTaskContext.loadHistory(MySqlTaskContext.java:164)
      	at io.debezium.connector.mysql.MySqlConnectorTask.start(MySqlConnectorTask.java:110)
      	at io.debezium.connector.common.BaseSourceTask.start(BaseSourceTask.java:104)
      	at org.apache.kafka.connect.runtime.WorkerSourceTask.execute(WorkerSourceTask.java:199)
      	at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:177)
      	at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:227)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: org.apache.kafka.connect.errors.DataException: Invalid Java object for schema type BOOLEAN: class java.lang.Short 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

            Activity

              People

              • Assignee:
                jpechanec Jiri Pechanec
                Reporter:
                viraj071 Viraj Shah
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: