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

fix(bigquery): parse timestamp query parameter with RFC3339 #6653

Merged
merged 1 commit into from Sep 12, 2022

Conversation

alvarowolfx
Copy link
Contributor

Timestamps on BigQuery have a format similar to RFC3339.

When creating a Query Job via the API, users can pass a timestamp with string 2020-10-15T00:00:00Z, which is a valid parameter. But if a given Job was created with a TIMESTAMP following that format and is read back using this library, it fails (as reported on #6651 ) because we expect TIMESTAMPS to have only this format: "2006-01-02 15:04:05.999999-07:00"

This PR also tries to parse TIMESTAMPS using Go RFC3339Nano, similarly on how the civil.ParseDateTime function tries multiple formats.

Resolves #6651

@alvarowolfx alvarowolfx requested review from shollyman and a team September 12, 2022 21:24
@alvarowolfx alvarowolfx requested a review from a team as a code owner September 12, 2022 21:24
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: bigquery Issues related to the BigQuery API. labels Sep 12, 2022
@@ -416,7 +416,15 @@ func convertParamValue(qval *bq.QueryParameterValue, qtype *bq.QueryParameterTyp
if isNullScalar(qval) {
return NullTimestamp{Valid: false}, nil
}
return time.Parse(timestampFormat, qval.Value)
t, err := time.Parse(timestampFormat, qval.Value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Fallback for the win!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bigquery: Timestamp is not parsed correctly
2 participants