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

Use a random dataset and table name for simple_bq_source #1801

Merged
merged 1 commit into from
Aug 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions sdk/python/tests/utils/data_source_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import contextlib
import random
import tempfile
import time

from google.cloud import bigquery

Expand All @@ -25,7 +27,7 @@ def simple_bq_source_using_table_ref_arg(
) -> BigQuerySource:
client = bigquery.Client()
gcp_project = client.project
bigquery_dataset = "ds"
bigquery_dataset = f"ds_{time.time_ns()}"
dataset = bigquery.Dataset(f"{gcp_project}.{bigquery_dataset}")
client.create_dataset(dataset, exists_ok=True)
dataset.default_table_expiration_ms = (
Expand All @@ -34,7 +36,7 @@ def simple_bq_source_using_table_ref_arg(
* 60 # 60 minutes in milliseconds (seems to be minimum limit for gcloud)
)
client.update_dataset(dataset, ["default_table_expiration_ms"])
table_ref = f"{gcp_project}.{bigquery_dataset}.table_1"
table_ref = f"{gcp_project}.{bigquery_dataset}.table_{random.randrange(100, 999)}"

job = client.load_table_from_dataframe(
df, table_ref, job_config=bigquery.LoadJobConfig()
Expand Down