jdbcdebezium

Debezium convert types


I have a MySQL column which should store a boolean value. My Django driver models this with a TINYINT value. I want to replicate this data in a PostgreSQL but there this column is a BOOLEAN.

The debezium JDBC sink connector tries to change the schema (which is disabled) and throws an error.

How can I convert/transform the TINYINT to BOOLEAN in the JDBC sink connector?

A similar issue I will probably get with the Django duration field (BIGINT in MySQL to INTERVAL in PostgreSQL), but I hope understanding the boolean conversion will help me understand this case too.


Solution

  • By adding

    {
      ...
      "converters": "tinyint-one-to-boolean,jdbc-sink,duration-converter",
      "tinyint-one-to-boolean.type": "io.debezium.connector.binlog.converters.TinyIntOneToBooleanConverter",
      "tinyint-one-to-boolean.length.checker": "false",
      "jdbc-sink.type": "io.debezium.connector.binlog.converters.JdbcSinkDataTypesConverter",
      "tinyint-one-to-boolean.selector": "my_database.my_table.my_column,my_database.my_table.other_column",
      "jdbc-sink.selector.boolean": "my_database.my_table.my_column,my_database.my_table.other_column",
      ...
    }
    

    to my source connector config I was able to replicate the tinyint as boolean in PostgreSQL.

    see also https://debezium.io/documentation/reference/stable/connectors/mysql.html#_tinyint1_to_boolean