📅  最后修改于: 2022-03-11 14:46:27.740000             🧑  作者: Mango
def save_to_bq_table():
bq_client = bigquery.Client()
# Saving data to a intermediate table then export it to GCS
query = "##Query with millions of records results##"
job_config = bigquery.QueryJobConfig()
# Set the destination table
table_ref = bq_client.dataset(dataset_id).table('TableID')
job_config.destination = table_ref
job_config.allow_large_results = True
# Start the query, passing in the extra configuration.
query_job = bq_client.query(
query,
location='US', # Location must match that of the source table
job_config=job_config) # API request - starts the query
query_job.result() # Waits for the query to finish