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

[source-mysql] 7084 source mysql regression in 39x date parsing errors #49932

Merged

Conversation

rodireich
Copy link
Contributor

@rodireich rodireich commented Dec 19, 2024

What

A saved state timestamp with timezone may have a variation due to legacy mysql:

  • may or may not include a decimal value for fraction of a second
  • May include a varying number of decimal fraction points.
  • May or may not include an offset
  • May or may not include a space before offset
    We need to be able to parse all variations in order to be backward compatible with existing states saved by legacy connector.
    Once a state was read we should always emit a normalized value when saving back to state.

How

Rather than relying on fallback default Jsons.valueToTree() we are declaring a datetime formatter that can accommodate all above variations.

User Impact

This should fix syncs jobs that are failing to start to to cursor values saved in an unexpected format.

Can this PR be safely reverted and rolled back?

  • YES 💚
  • NO ❌

Copy link

vercel bot commented Dec 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
airbyte-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 19, 2024 3:21pm

.optionalEnd()
.appendOffset("+HH:mm", "Z")
.optionalEnd()
.toFormatter()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is painful 😓

Copy link
Contributor

Choose a reason for hiding this comment

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

I found chatgpt useful for generating this kind of code. Even so, it's still annoying.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It actually gave me wrong advice here, much to my delight
maybe humans still got a chance 🤭

Copy link
Contributor

Choose a reason for hiding this comment

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

yay humans!

val offsetDateTime =
try {
OffsetDateTime.parse(stateValue, formatter)
} catch (_: DateTimeParseException) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If value include no +xx:xx or Z then we create an offset datetime with an assumed UTC offset.
This is done via a LocalDate.

@rodireich rodireich marked this pull request as ready for review December 19, 2024 01:03
@rodireich rodireich requested a review from a team as a code owner December 19, 2024 01:03
@theyueli theyueli changed the title 7084 source mysql regression in 39x date parsing errors [source-mysql] 7084 source mysql regression in 39x date parsing errors Dec 19, 2024
.optionalEnd()
.appendOffset("+HH:mm", "Z")
.optionalEnd()
.toFormatter()
Copy link
Contributor

Choose a reason for hiding this comment

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

I found chatgpt useful for generating this kind of code. Even so, it's still annoying.

} catch (_: DateTimeParseException) {
// if no offset exists, we assume it's UTC
LocalDateTime.parse(stateValue, formatter)
.atOffset(java.time.ZoneOffset.UTC)
Copy link
Contributor

Choose a reason for hiding this comment

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

why the qualified class name??

"'2025-09-03T05:23:35Z', '2025-09-03T05:23:35.000000Z'",
"'2025-09-03T05:23:35 Z', '2025-09-03T05:23:35.000000Z'",
"'2025-09-03T05:23:35.12345 +12:34', '2025-09-03T05:23:35.123450+12:34'",
)
Copy link
Contributor

Choose a reason for hiding this comment

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

excellent

@rodireich rodireich enabled auto-merge (squash) December 19, 2024 15:12
@rodireich rodireich merged commit 8819bd1 into master Dec 19, 2024
33 checks passed
@rodireich rodireich deleted the 7084-source-mysql--regression-in-39x-date-parsing-errors branch December 19, 2024 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues area/documentation Improvements or additions to documentation connectors/source/mysql
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants