Skip to content

Commit af4920b

Browse files
committed
Store timezone aware snapshot time on snapshots
1 parent 47e1a58 commit af4920b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

google/cloud/bigquery/table.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,10 +1306,9 @@ def __init__(self, resource: Dict[str, Any]):
13061306

13071307
self.snapshot_time = None
13081308
if "snapshotTime" in resource:
1309-
dt = google.cloud._helpers._rfc3339_to_datetime(resource["snapshotTime"])
1310-
# The helper returns a timezone *aware* datetime object (with UTC tzinfo),
1311-
# we need to make it naive.
1312-
self.snapshot_time = dt.replace(tzinfo=None)
1309+
self.snapshot_time = google.cloud._helpers._rfc3339_to_datetime(
1310+
resource["snapshotTime"]
1311+
)
13131312

13141313

13151314
class Row(object):

tests/unit/test_table.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ def test_snapshot_definition_not_set(self):
692692
assert table.snapshot_definition is None
693693

694694
def test_snapshot_definition_set(self):
695+
from google.cloud._helpers import UTC
695696
from google.cloud.bigquery.table import SnapshotDefinition
696697

697698
dataset = DatasetReference(self.PROJECT, self.DS_ID)
@@ -714,7 +715,7 @@ def test_snapshot_definition_set(self):
714715
"/projects/project_x/datasets/dataset_y/tables/table_z"
715716
)
716717
assert snapshot.snapshot_time == datetime.datetime(
717-
2010, 9, 28, 10, 20, 30, 123000
718+
2010, 9, 28, 10, 20, 30, 123000, tzinfo=UTC
718719
)
719720

720721
def test_description_setter_bad_value(self):

0 commit comments

Comments
 (0)