这是indexloc提供的服务,不要输入任何密码
Skip to content

bigquery: failing to parse some BQ query parameter dates and datetimes #11875

@ash-ddog

Description

@ash-ddog

Client

cloud.google.com/go/bigquery v1.64.0

Environment

go 1.24.1

Code and Dependencies

Stack trace (this is specifically for dates, but probably same area for datetime)

civil.ParseDate (civil.go:50) cloud.google.com/go/civil
bigquery.convertBasicType (value.go:987) cloud.google.com/go/bigquery
bigquery.convertParamValue (params.go:703) cloud.google.com/go/bigquery
bigquery.baToQueryParameter (params.go:602) cloud.google.com/go/bigquery
bigquery.bqToQueryConfig (query.go:286) cloud.google.com/go/bigquery
bigquery.bqToJobConfig (job.go:157) cloud.google.com/go/bigquery
bigquery. (*Job).Config (job.go:134) cloud.google.com/go/bigquery

Expected behavior

Can retrieve a job config via job.Confg() without error

Actual behavior

job.Config() returns an error when trying to parse a BQ query param value of type DATE/DATETIME

Additional context

Saw this older issue but has been closed and not exactly sure it's related: #6409

I see two classes of error

  1. Parsing date: dates are in format YYYY-M-D but trying to be parsed as YYYY-MM-DD (i.e. civil.ParseDate)
parsing time "2021-10-1" as "2006-01-02": cannot parse "1" as "02"
parsing time "2022-1-1" as "2006-01-02": cannot parse "1-1" as "01"
parsing time "2024-1-21" as "2006-01-02": cannot parse "1-21" as "01"
parsing time "2024-8-1" as "2006-01-02": cannot parse "8-1" as "01"
parsing time "2024-11-7" as "2006-01-02": cannot parse "7" as "02"
parsing time "2025-1-1" as "2006-01-02": cannot parse "1-1" as "01"
parsing time "2025-2-21" as "2006-01-02": cannot parse "2-21" as "01"
parsing time "2025-3-3" as "2006-01-02": cannot parse "3-3" as "01"
parsing time "2025-3-5" as "2006-01-02": cannot parse "3-5" as "01"
parsing time "2025-3-8" as "2006-01-02": cannot parse "3-8" as "01"
parsing time "2025-3-12" as "2006-01-02": cannot parse "3-12" as "01"
parsing time "2025-3-16" as "2006-01-02": cannot parse "3-16" as "01"
parsing time "2025-3-17" as "2006-01-02": cannot parse "3-17" as "01"
parsing time "2025-3-18" as "2006-01-02": cannot parse "3-18" as "01"
parsing time "2025-3-19" as "2006-01-02": cannot parse "3-19" as "01"
parsing time "2025-3-21" as "2006-01-02": cannot parse "3-21" as "01"
  1. Parsing datetime: datetime is in format YYYY-MM-DD HH:MM:SS UTC but trying to parse as YYYY-MM-DDTHH:MM:SS[.FFFFFFFFF] (i.e. civil.ParseDateTime)
parsing time "2025-03-19 07:00:00 UTC": extra text: " UTC"
parsing time "2025-03-19 08:00:00 UTC": extra text: " UTC"
parsing time "2025-03-19 09:00:00 UTC": extra text: " UTC"
parsing time "2025-03-19 10:00:00 UTC": extra text: " UTC"
parsing time "2025-03-19 11:00:00 UTC": extra text: " UTC"
parsing time "2025-03-19 12:00:00 UTC": extra text: " UTC"
parsing time "2025-03-19 13:00:00 UTC": extra text: " UTC"
parsing time "2025-03-19 14:00:00 UTC": extra text: " UTC"

Also for context: These errors are occurring in GCP projects we query on behalf of our customers, so we don't actually have access to these projects to look at the details of these jobs (i.e. I do not/can not know how these jobs end up with the query parameter values).

Please let me know if I can provide additional info. Also happy to try to open a PR (but I would probably just stop using civil.ParseDate and civil.ParseDateTime).

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the BigQuery API.priority: p2Moderately-important priority. Fix may not be included in next release.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions