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

Postgres Connector: error of mismatching scale value for Decimal and Numeric data types

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Blocker Blocker
    • 0.5.2
    • 0.5.1
    • postgresql-connector
    • None
    • Hide

      create a table which containes a Decimal or Numeric column, for example:

      CREATE TABLE parrot.table_with_simple_pk
      (
      	id BIGSERIAL NOT NULL PRIMARY KEY,
      	n_smallint SMALLINT,
          n_integer INTEGER,
          n_bigint BIGINT,
          n_decimal DECIMAL(100, 50),
          n_numeric NUMERIC(100, 50),
          n_real REAL,
          n_double DOUBLE PRECISION
      )
      WITH (
        OIDS=FALSE
      );
      
      • Create and start Debezium with Postgres Connector configured to capture changes from the table just created:
      {
        "name": "PostgreSql_Connector",
        "config": {
          "connector.class": "io.debezium.connector.postgresql.PostgresConnector",
          "database.hostname": "postgres", 
          "database.port": "5432",
          "database.user": "postgres",
          "database.password": "postgres",
          "database.dbname" : "matteo",
          "database.server.name": "matteo_source",
          "table.whitelist": "matteo.table_with_simple_pk"
        }
      }
      
      • Insert a new row in the table
      Show
      create a table which containes a Decimal or Numeric column, for example: CREATE TABLE parrot.table_with_simple_pk ( id BIGSERIAL NOT NULL PRIMARY KEY, n_smallint SMALLINT, n_integer INTEGER, n_bigint BIGINT, n_decimal DECIMAL(100, 50), n_numeric NUMERIC(100, 50), n_real REAL, n_double DOUBLE PRECISION ) WITH ( OIDS=FALSE ); Create and start Debezium with Postgres Connector configured to capture changes from the table just created: { "name" : "PostgreSql_Connector" , "config" : { "connector.class" : "io.debezium.connector.postgresql.PostgresConnector" , "database.hostname" : "postgres" , "database.port" : "5432" , "database.user" : "postgres" , "database.password" : "postgres" , "database.dbname" : "matteo" , "database.server.name" : "matteo_source" , "table.whitelist" : "matteo.table_with_simple_pk" } } Insert a new row in the table

      A row insert or update in a Postgres table which cotains Numeric or Decimal data type raises the following error:

      debezium_1  | 	at org.apache.kafka.connect.data.Decimal.fromLogical(Decimal.java:69)
      debezium_1  | 	at org.apache.kafka.connect.json.JsonConverter$17.convert(JsonConverter.java:232)
      debezium_1  | 	at org.apache.kafka.connect.json.JsonConverter.convertToJson(JsonConverter.java:564)
      debezium_1  | 	at org.apache.kafka.connect.json.JsonConverter.convertToJson(JsonConverter.java:651)
      debezium_1  | 	at org.apache.kafka.connect.json.JsonConverter.convertToJson(JsonConverter.java:651)
      debezium_1  | 	at org.apache.kafka.connect.json.JsonConverter.convertToJsonWithEnvelope(JsonConverter.java:538)
      debezium_1  | 	at org.apache.kafka.connect.json.JsonConverter.fromConnectData(JsonConverter.java:291)
      debezium_1  | 	at org.apache.kafka.connect.runtime.WorkerSourceTask.sendRecords(WorkerSourceTask.java:197)
      debezium_1  | 	at org.apache.kafka.connect.runtime.WorkerSourceTask.execute(WorkerSourceTask.java:167)
      debezium_1  | 	at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:139)
      debezium_1  | 	at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:182)
      debezium_1  | 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      debezium_1  | 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      debezium_1  | 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      debezium_1  | 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      debezium_1  | 	at java.lang.Thread.run(Thread.java:748)
      debezium_1  | 2017-06-16 06:00:01,025 ERROR  ||  Task is being killed and will not recover until manually restarted  
      

              Unassigned Unassigned
              teocapo_jira Matteo Capitanio (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 hours
                  2h