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

JDBC connector wrongly uses default value when value is NULL on optional fields

XMLWordPrintable

    • Critical

      Hello~, I have encountered a problem with the default value of the field, The source table is not consistent with the target table , for example:

       

      This is a piece of json data from id=1 
      {
      "schema": {
      "type": "struct",
      "fields": [
      {
      "type": "struct",
      "fields": [

      { "type": "int32", "optional": false, "field": "id" }

      ,

      { "type": "string", "optional": true, "default": "zhangsan", "field": "name" }

      ,

      { "type": "int32", "optional": true, "field": "age" }

      ,

      { "type": "string", "optional": true, "field": "timestamp" }

      ,

      { "type": "string", "optional": true, "default": "1", "field": "char" }

      ,

      { "type": "int32", "optional": true, "default": 100, "field": "int" }

      ],
      "optional": true,
      "name": "Mysql_140.wangzc_test.a_wzc_default_value.Value",
      "field": "before"
      },
      {
      "type": "struct",
      "fields": [

      { "type": "int32", "optional": false, "field": "id" }

      ,

      { "type": "string", "optional": true, "default": "zhangsan", "field": "name" }

      ,

      { "type": "int32", "optional": true, "field": "age" }

      ,

      { "type": "string", "optional": true, "field": "timestamp" }

      ,

      { "type": "string", "optional": true, "default": "1", "field": "char" }

      ,

      { "type": "int32", "optional": true, "default": 100, "field": "int" }

      ],
      "optional": true,
      "name": "Mysql_140.wangzc_test.a_wzc_default_value.Value",
      "field": "after"
      },
      {
      "type": "struct",
      "fields": [

      { "type": "string", "optional": false, "field": "version" }

      ,

      { "type": "string", "optional": false, "field": "connector" }

      ,

      { "type": "string", "optional": false, "field": "name" }

      ,

      { "type": "int64", "optional": false, "field": "ts_ms" }

      ,
      {
      "type": "string",
      "optional": true,
      "name": "io.debezium.data.Enum",
      "version": 1,
      "parameters":

      { "allowed": "true,last,false,incremental" }

      ,
      "default": "false",
      "field": "snapshot"
      },

      { "type": "string", "optional": false, "field": "db" }

      ,

      { "type": "string", "optional": true, "field": "sequence" }

      ,

      { "type": "string", "optional": true, "field": "table" }

      ,

      { "type": "int64", "optional": false, "field": "server_id" }

      ,

      { "type": "string", "optional": true, "field": "gtid" }

      ,

      { "type": "string", "optional": false, "field": "file" }

      ,

      { "type": "int64", "optional": false, "field": "pos" }

      ,

      { "type": "int32", "optional": false, "field": "row" }

      ,

      { "type": "int64", "optional": true, "field": "thread" }

      ,

      { "type": "string", "optional": true, "field": "query" }

      ],
      "optional": false,
      "name": "io.debezium.connector.mysql.Source",
      "field": "source"
      },

      { "type": "string", "optional": false, "field": "op" }

      ,

      { "type": "int64", "optional": true, "field": "ts_ms" }

      ,
      {
      "type": "struct",
      "fields": [

      { "type": "string", "optional": false, "field": "id" }

      ,

      { "type": "int64", "optional": false, "field": "total_order" }

      ,

      { "type": "int64", "optional": false, "field": "data_collection_order" }

      ],
      "optional": true,
      "name": "event.block",
      "version": 1,
      "field": "transaction"
      }
      ],
      "optional": false,
      "name": "Mysql_140.wangzc_test.a_wzc_default_value.Envelope",
      "version": 1
      },
      "payload": {
      "before": null,
      "after":

      { "id": 1, "name": null, "age": 18, "timestamp": null, "char": null, "int": null }

      ,
      "source":

      { "version": "2.4.0.Final", "connector": "mysql", "name": "Mysql_140", "ts_ms": 1701065788000, "snapshot": "first", "db": "wangzc_test", "sequence": null, "table": "a_wzc_default_value", "server_id": 0, "gtid": null, "file": "master.000018", "pos": 883521573, "row": 0, "thread": null, "query": null }

      ,
      "op": "r",
      "ts_ms": 1701065788073,
      "transaction": null
      }
      }

              rh-ee-mvitale Mario Fiore Vitale
              anzongchaowang Wang Wang (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: