Skip to content

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

Merged
alvarowolfx merged 1 commit intogoogleapis:mainfrom
alvarowolfx:bq-query-timestamp-parse
Sep 12, 2022
Merged

fix(bigquery): parse timestamp query parameter with RFC3339#6653
alvarowolfx merged 1 commit intogoogleapis:mainfrom
alvarowolfx:bq-query-timestamp-parse

Conversation

@alvarowolfx
Copy link
Copy Markdown
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 a team and shollyman 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
Comment thread bigquery/params.go
return NullTimestamp{Valid: false}, nil
}
return time.Parse(timestampFormat, qval.Value)
t, err := time.Parse(timestampFormat, qval.Value)
Copy link
Copy Markdown
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