Skip to content

Commit 9fa614b

Browse files
shollymantseaver
authored andcommitted
BigQuery: verify bounds for bigquery_undelete_table snippet (googleapis#5712)
1 parent 3829f6e commit 9fa614b

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

docs/bigquery/snippets.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,6 +2157,13 @@ def test_undelete_table(client, to_delete):
21572157
# time for recovering the table.
21582158
snapshot_time = int(time.time() * 1000)
21592159

2160+
# Because local system time may have some drift, we ensure the snapshot
2161+
# time is at least within the creation lifespan of the table. Trying
2162+
# to snapshot a table prior to its creation time is an error.
2163+
table = client.get_table(table_ref)
2164+
if table.created_time > snapshot_time:
2165+
snapshot_time = table.created_time
2166+
21602167
# "Accidentally" delete the table.
21612168
client.delete_table(table_ref) # API request
21622169

0 commit comments

Comments
 (0)