Status
Current state: Under Discussion
Discussion thread: https://lists.apache.org/thread/lxfq8y8co76mjwxhowwx6cjl0hw1mxpy
JIRA:
Motivation
In particular, if we use Debezium to stream changes out of a table, t1, in mysql:
create table t1 { name varchar(40) not null, create_time datetime default '1999-01-01 11:11:11' null, update_time datetime default '1999-01-01 11:11:11' null }
INSERT INTO `t1` (`name`, `update_time`) VALUES ('kafka', null);
the record will store in MySQL as:
{ "name": "kafka", "create_time": "1999-01-01 11:11:11", "update_time": null }
{ "name": "kafka", "create_time": "1999-01-01 11:11:11", "update_time": "1999-01-01 11:11:11" }
Public Interfaces
Add two configurations to JsonConverter:
Name: serialize.use.optional.null
Description: Whether to serialize fields that have a default value and that are null to the default value or to null. When set to false, the default value is used, otherwise null is used.
Type: Boolean
Default: false
Name: deserialize.use.optional.null
Description: Whether to deserialize fields that have a default value and that are null to the default value or to null. When set to false, the default value is used, otherwise null is used.
Type: Boolean
Default: false
Proposed Changes
Update JsonConverter and JsonConverterConfig to handle the new configurations.
Compatibility, Deprecation, and Migration Plan
The new configurations keep the current behavior by default so it will not affect existing users. Users can optionally opt-in the new behavior by setting the configuration to true.
Rejected Alternatives
null
on an optionalnull