-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mysql,postgres] Change Debezium conversion for timestamp types #317
Conversation
return timeValue.UnixMicro(), nil | ||
} | ||
|
||
type ZonedTimestampConverter struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically renamed ZonedTimestampConverter
to TimestampConverter
and updated the DebeziumType
appropriately.
@@ -67,18 +67,37 @@ func (DateConverter) Convert(value any) (any, error) { | |||
return int32(timeValue.Unix() / (60 * 60 * 24)), nil | |||
} | |||
|
|||
type TimestampConverter struct{} | |||
type MicroTimestampConverter struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a new MicroTimestampConverter
.
_, err := converter.Convert(1234) | ||
assert.ErrorContains(t, err, "expected time.Time got int with value: 1234") | ||
} | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to worry about dates > 9999 or < 0 for MicroTimestamps since it uses an int64 and won't have JSON encoding issues.
} | ||
{ | ||
// Date < 0 | ||
value, err := converter.Convert(time.Date(-1, 2, 3, 4, 5, 0, 0, time.UTC)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For these tests, can we have it also run against Transfer to ensure Transfer is able to parse it correctly?
Like run it against this function: https://github.com/artie-labs/transfer/blob/52a52c9cbe92e506c7d4a24757440979d28ef8a8/lib/debezium/types.go#L72
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Logged the schema that Debezium outputs when run against Postgres:
And the data:
This changes the converters used for MySQL and Postgres to be in line with what Debezium does:
datetime
->io.debezium.time.MicroTimestamp
timestamp
->io.debezium.time.ZonedTimestamp
timestamp with time zone
->io.debezium.time.ZonedTimestamp
timestamp without time zone
->io.debezium.time.MicroTimestamp