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

snapshot_definition.snapshot_time throws exception #1986

Open
mars-lan opened this issue Aug 1, 2024 · 0 comments
Open

snapshot_definition.snapshot_time throws exception #1986

mars-lan opened this issue Aug 1, 2024 · 0 comments
Assignees
Labels
api: bigquery Issues related to the googleapis/python-bigquery API.

Comments

@mars-lan
Copy link

mars-lan commented Aug 1, 2024

Environment details

  • OS type and version: macOS 14.5
  • Python version: 3.8
  • pip version: 23.3.1
  • google-cloud-bigquery version: 3.25.0

Steps to reproduce

  1. Create a snapshot table
  2. Retrieve snapshot time from snapshot_definition.snapshot_time

Code example

# get a snapshot table
bq_table = client.get_table(...) 

# throws exception
bq_table.snapshot_definition.snapshot_time

Stack trace

...
  File "/usr/local/lib/python3.8/site-packages/google/cloud/bigquery/table.py", line 976, in snapshot_definition
    snapshot_info = SnapshotDefinition(snapshot_info)
  File "/usr/local/lib/python3.8/site-packages/google/cloud/bigquery/table.py", line 1372, in __init__
    self.snapshot_time = google.cloud._helpers._rfc3339_to_datetime(
  File "/usr/local/lib/python3.8/site-packages/google/cloud/_helpers/__init__.py", line 252, in _rfc3339_to_datetime
    return datetime.datetime.strptime(dt_str, _RFC3339_MICROS).replace(tzinfo=UTC)
  File "/usr/local/lib/python3.8/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/usr/local/lib/python3.8/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '2024-07-23T09:09:09Z' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'

Seems like the library is incorrectly expecting the date string to contain the millisecond portion.

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Aug 2, 2024
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 googleapis/python-bigquery API.
Projects
None yet
Development

No branches or pull requests

2 participants