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

MySQL connector cannot parse default value of decimal colum enclosed in double quotes

XMLWordPrintable

    • False
    • None
    • False

      The issue is reproducible on Debezum v1.9.5.Final and may have been introduced by DBZ-5134.

      Consider the following DDL:

      mysql> create table t(c1 decimal(26,6) default "1");
      Query OK, 0 rows affected (0.02 sec)
      

      Once recovered from the database history, this DDL will cause a parser failure like the following:

      java.lang.NumberFormatException: Character " is neither a decimal digit number, decimal point, nor "e" notation exponential mark.
      	at java.base/java.math.BigDecimal.<init>(BigDecimal.java:518)
      	at java.base/java.math.BigDecimal.<init>(BigDecimal.java:401)
      	at java.base/java.math.BigDecimal.<init>(BigDecimal.java:834)
      	at io.debezium.connector.mysql.MySqlDefaultValueConverter.convertToDecimal(MySqlDefaultValueConverter.java:291)
      	at io.debezium.connector.mysql.MySqlDefaultValueConverter.convert(MySqlDefaultValueConverter.java:160)
      	at io.debezium.connector.mysql.MySqlDefaultValueConverter.parseDefaultValue(MySqlDefaultValueConverter.java:96)
      	at io.debezium.relational.TableSchemaBuilder.lambda$addField$9(TableSchemaBuilder.java:393)
      	at java.base/java.util.Optional.flatMap(Optional.java:294)
      	at io.debezium.relational.TableSchemaBuilder.addField(TableSchemaBuilder.java:393)
      	at io.debezium.relational.TableSchemaBuilder.lambda$create$2(TableSchemaBuilder.java:149)
      	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:147)
      	at io.debezium.relational.RelationalDatabaseSchema.buildAndRegisterSchema(RelationalDatabaseSchema.java:135)
      	at io.debezium.relational.HistorizedRelationalDatabaseSchema.recover(HistorizedRelationalDatabaseSchema.java:65)
      	at io.debezium.schema.HistorizedDatabaseSchema.recover(HistorizedDatabaseSchema.java:38)
      	at io.debezium.connector.mysql.MySqlConnectorTask.validateAndLoadDatabaseHistory(MySqlConnectorTask.java:353)
      	at io.debezium.connector.mysql.MySqlConnectorTask.start(MySqlConnectorTask.java:107)
      	at io.debezium.connector.common.BaseSourceTask.start(BaseSourceTask.java:130)
      	at org.apache.kafka.connect.runtime.WorkerSourceTask.execute(WorkerSourceTask.java:232)
      	at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:186)
      	at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:241)
      	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      	at java.base/java.lang.Thread.run(Thread.java:829)
      

      The issue could be also reproduced by adding the following column to the recently added parser test:

      diff --git a/debezium-connector-mysql/src/test/java/io/debezium/connector/mysql/MySqlDefaultValueTest.java b/debezium-connector-mysql/src/test/java/io/debezium/connector/mysql/MySqlDefaultValueTest.java
      index f69bee794..08204ce03 100644
      --- a/debezium-connector-mysql/src/test/java/io/debezium/connector/mysql/MySqlDefaultValueTest.java
      +++ b/debezium-connector-mysql/src/test/java/io/debezium/connector/mysql/MySqlDefaultValueTest.java
      @@ -595,6 +595,7 @@ public void parseNumericAndDecimalToIntDefaultValue() {
                       + "c3 bigint not null default .12345,\n"
                       + "c4 smallint not null default 100.52345,\n"
                       + "c5 int not null default '-.789',\n"
      +                + "c6 decimal(26,6) default \"1\",\n"
                       + "PRIMARY KEY (`id`)\n"
                       + ")";
               parser.parse(ddl, tables);
      

      According to the above test, the issue is reproducible on the latest 1.9 (3244bb7)

              Unassigned Unassigned
              sergeimorozov Sergei Morozov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: