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-bigquery-batch: Fix behavior of DATETIME cursors with fractional-second precision #2086

Merged
merged 3 commits into from
Oct 24, 2024

Conversation

willdonnelly
Copy link
Member

@willdonnelly willdonnelly commented Oct 24, 2024

Description:

BigQuery DATETIME columns only support microsecond precision, but the default serialization of the Go civil.DateTime struct uses nanosecond precision. Which is fine for output only, and also is fine for cursors until the capture restarts, and also is fine when the datetime values are whole seconds.

But a fractional-second datetime used as a cursor will be stored as a string in the state checkpoint, and trying to feed that back to BigQuery after a restart will produce an error because there are too many digits of precision.

The fix is to handle the formatting of civil.DateTime values into strings ourselves and make sure it only has six digits.


This change is Reviewable

This will make it easier to write short tests of other scenarios.
BigQuery DATETIME columns only support microsecond precision, but
the default serialization of the Go `civil.DateTime` struct uses
nanosecond precision. Which is fine for output only, and *also*
is fine for cursors until the capture restarts, and *also* is
fine when the datetime values are whole seconds.

But a fractional-second datetime used as a cursor will be stored
as a string in the state checkpoint, and trying to feed that back
to BigQuery after a restart will produce an error because there
are too many digits of precision.

The fix is to handle the formatting of `civil.DateTime` values
into strings ourselves and make sure it only has six digits.
@willdonnelly willdonnelly requested a review from a team October 24, 2024 19:02
Copy link
Member

@williamhbaker williamhbaker left a comment

Choose a reason for hiding this comment

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

LGTM

@willdonnelly willdonnelly merged commit 4fa0a96 into main Oct 24, 2024
53 checks passed
@willdonnelly willdonnelly deleted the wgd/bigquery-datetime-cursors-20241024 branch October 24, 2024 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.

2 participants