Skip to content
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

Convert MySQL datetime string to ISO8601 #122

Merged
merged 7 commits into from
Feb 18, 2025
Merged

Convert MySQL datetime string to ISO8601 #122

merged 7 commits into from
Feb 18, 2025

Conversation

notfelineit
Copy link
Contributor

@notfelineit notfelineit commented Feb 14, 2025

Airbyte specifies that MySQL datetime/timestamp/date strings need to be parsed into ISO8601 format. This PR does that and also adds an extra log about whether we are looking for a COPY COMPLETED event or a stop position.

@notfelineit notfelineit marked this pull request as ready for review February 14, 2025 19:32
@notfelineit notfelineit changed the title Add log indicating whether we are looking for a stop position or a COPY COMPLETED Convert MySQL datetime string to ISO8601 Feb 14, 2025
@@ -160,6 +161,8 @@ func parseValue(val sqltypes.Value, columnType string) sqltypes.Value {
} else if strings.HasPrefix(columnType, "set") {
values := parseEnumOrSetValues(columnType)
return mapSetValue(val, values)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the enum and set code above is wrong after vitessio/vitess#15723

That work is in v20+ in OSS and private.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll remove it once everyone is on 20+ 😄 By "wrong" do you mean "unnecessary" or do you mean it will actually return the wrong values?

Copy link

@mattlord mattlord Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be wrong if the user has string values in the ENUM/SET that can be converted to integers. For example, the string value may be 2 but it's not the index value of 2.

And we can do this work only when necessary by doing it conditional on:

  1. We're NOT in the copy phase
  2. The EnumSetStringValues != TRUE

See: https://github.com/vitessio/vitess/blob/main/changelog/20.0/20.0.0/summary.md#enum-set-vstream

That is exactly what they did in the Debezium connector.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 We will address this in the next PR!

@@ -160,6 +161,8 @@ func parseValue(val sqltypes.Value, columnType string) sqltypes.Value {
} else if strings.HasPrefix(columnType, "set") {
values := parseEnumOrSetValues(columnType)
return mapSetValue(val, values)
} else if lowerCased := strings.ToLower(columnType); strings.HasPrefix(lowerCased, "time") || strings.HasPrefix(lowerCased, "date") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not have an actual type here? If not, then using the MySQL column type string that we include works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CleanShot 2025-02-18 at 08 36 39@2x

Do you mean these methods? I can use them but wondering how to handle date?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: we talked offline and I modified the code to use Type!

@notfelineit notfelineit merged commit 0c0cb75 into main Feb 18, 2025
3 checks passed
@notfelineit notfelineit deleted the add-log branch February 18, 2025 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants