Skip to content

Commit

Permalink
docs: remove redundant bigquery_update_table_expiration code sample (
Browse files Browse the repository at this point in the history
…#1673)

New version of this sample added in #1457 and migrated to in the docs in internal change 570781706.

Co-authored-by: Lingqing Gan <lingqing.gan@gmail.com>
  • Loading branch information
tswast and Linchin authored Oct 19, 2023
1 parent a40d7ae commit 2dded33
Showing 1 changed file with 0 additions and 46 deletions.
46 changes: 0 additions & 46 deletions docs/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,52 +203,6 @@ def test_update_table_description(client, to_delete):
# [END bigquery_update_table_description]


@pytest.mark.skip(
reason=(
"update_table() is flaky "
"https://github.com/GoogleCloudPlatform/google-cloud-python/issues/5589"
)
)
def test_update_table_expiration(client, to_delete):
"""Update a table's expiration time."""
dataset_id = "update_table_expiration_dataset_{}".format(_millis())
table_id = "update_table_expiration_table_{}".format(_millis())
project = client.project
dataset_ref = bigquery.DatasetReference(project, dataset_id)
dataset = bigquery.Dataset(dataset_ref)
client.create_dataset(dataset)
to_delete.append(dataset)

table = bigquery.Table(dataset.table(table_id), schema=SCHEMA)
table = client.create_table(table)

# TODO(thejaredchapman): After code sample has been updated from cloud.google.com delete this.

# [START bigquery_update_table_expiration]
import datetime

# from google.cloud import bigquery
# client = bigquery.Client()
# project = client.project
# dataset_ref = bigquery.DatasetReference(project, dataset_id)
# table_ref = dataset_ref.table('my_table')
# table = client.get_table(table_ref) # API request

assert table.expires is None

# set table to expire 5 days from now
expiration = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(
days=5
)
table.expires = expiration
table = client.update_table(table, ["expires"]) # API request

# expiration is stored in milliseconds
margin = datetime.timedelta(microseconds=1000)
assert expiration - margin <= table.expires <= expiration + margin
# [END bigquery_update_table_expiration]


@pytest.mark.skip(
reason=(
"update_table() is flaky "
Expand Down

0 comments on commit 2dded33

Please sign in to comment.