Details
-
Bug
-
Resolution: Unresolved
-
Major
-
2.1.1.Final
-
None
-
False
-
None
-
False
Description
In order to make your issue reports as actionable as possible, please provide the following information, depending on the issue type.
Bug report
For bug reports, provide this information, please:
What Debezium connector do you use and what version?
MySQL connector 1.9.7
What behaviour do you expect?
Custom Converter should take an input that differentiates NULL from 0000-00-00 and 0001-01-01 from 0000-00-00.
What behaviour do you see?
NULL and 0000-00-00 (any zero datetime) are all encoded as a zero timestamp.
Do you see the same behaviour using the latest relesead Debezium version?
Yes
Here is my custom converter. Note it can't different between NULL and 0000-00-00 properly. NULL will be returned as 0000-00-00 by the converter because a zero timestamp is used to represent both values.
```
import io.debezium.spi.converter.CustomConverter;
import io.debezium.spi.converter.RelationalColumn;
import org.apache.kafka.connect.data.SchemaBuilder;
import org.apache.kafka.connect.data.Struct;
import java.util.Properties;
public class DatetimeValueConverter implements CustomConverter<SchemaBuilder, RelationalColumn> {
private SchemaBuilder datetimeSchema;
@Override
public void configure(Properties props)
@Override
public void converterFor(RelationalColumn column,
ConverterRegistration<SchemaBuilder> registration) {
if ("DATETIME".equals(column.typeName()) || "TIMESTAMP".equals(column.typeName()) || "DATE".equals(column.typeName())) {
registration.register(datetimeSchema, x ->
else if(x.toString().equals("0") || x.toString().equals("1970-01-01T00:00:00Z") || x.toString().equals("1970-01-01T00:00Z"))
{ //NULL and 0000-00-00 and 0001-00-00 will all hit here return("0000-00-00"); } else return x.toString();
});
}
}
}```