Search code examples
mysqlapache-kafkaapache-kafka-connectdebezium

Debezium and Float data type


I have a float data type in MySQL I tried all the decimal converters, but every time, I'm getting a wrong value

Source data type float(3,2)

Value inserted: 32.43

Value from Kafka topic: 9.99

Any idea why the conversion is not happening properly?

Update: 2021-07-26

I found that this is from MySQL side because MySQL itself stores this value in that format. Even binlog stores it as 9.99 only.


Solution

  • Kafka or Debezium didn't generate this issue, it is from MySQL. I checked the table and binlog, the value was 9.99 only.

    Table DDL:

    CREATE TABLE `table1` (
      `id` int(11) NOT NULL,
      `name` varchar(100) DEFAULT NULL,
      `point` decimal(3,2) DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1
    
    insert into table2 values (29,'bbb',32.43);
    
    select * from table1;
    | 29 | bbb  |  9.99 |
    

    But there was a warning.

    Out of range value for column 'point' at row 1
    

    Credits:

    I asked this question in MySQL's slack community. Graham Halsey helped me to understand this issue.

    float(3,2) means you can store 3 digits, 2 of which are after the decimal point