原表
MySqlSource
MySqlSource.<String>builder()
.hostname(hostname)
.port(port)
.databaseList(database)
.tableList(tableList)
.username(username)
.password(password)
.deserializer(new JsonDebeziumDeserializationSchema())
.startupOptions(startupOptions)
.connectionPoolSize(connectionPoolSize)
.fetchSize(fetchSize)
.splitSize(splitSize)
.build();
读取到的数据
{
"before": null,
"after": {
"id": "eqp001",
"eqp_decimal": "BfY=",
"eqp_int": 45,
"eqp_datetime": 1687996800000,
"eqp_filter": "aaa"
},
"source": {
"version": "1.6.4.Final",
"connector": "mysql",
"name": "mysql_binlog_source",
"ts_ms": 0,
"snapshot": "false",
"db": "develop",
"sequence": null,
"table": "equipment",
"server_id": 0,
"gtid": null,
"file": "",
"pos": 0,
"row": 0,
"thread": null,
"query": null
},
"op": "r",
"ts_ms": 1688351819480,
"transaction": null
}
修改MySqlSource的反序列化
Map<String, Object> configs = new HashMap<>();
//转换decimal类型
configs.put(JsonConverterConfig.DECIMAL_FORMAT_CONFIG, DecimalFormat.NUMERIC.name());
MySqlSource.<String>builder()
.hostname(hostname)
.port(port)
.databaseList(database)
.tableList(tableList)
.username(username)
.password(password)
.deserializer(new JsonDebeziumDeserializationSchema(false,configs))
.startupOptions(startupOptions)
.connectionPoolSize(connectionPoolSize)
.fetchSize(fetchSize)
.splitSize(splitSize)
.build();
新读取到的数据
{
"before": null,
"after": {
"id": "eqp001",
"eqp_decimal": 15.26,
"eqp_int": 45,
"eqp_datetime": 1687996800000,
"eqp_filter": "aaa"
},
"source": {
"version": "1.6.4.Final",
"connector": "mysql",
"name": "mysql_binlog_source",
"ts_ms": 0,
"snapshot": "false",
"db": "develop",
"sequence": null,
"table": "equipment",
"server_id": 0,
"gtid": null,
"file": "",
"pos": 0,
"row": 0,
"thread": null,
"query": null
},
"op": "r",
"ts_ms": 1688352094669,
"transaction": null
}