嗨,我想根据大型表中的event_type将一个大型bigquery表(100亿个事件记录)分割成多个表。
注意,events表是分区的时间/日/事件_时间。进一步假设它是一个数据年(365天)
让我们假设事件_type=‘登录’,‘页面查看’
我的方法:
我的问题:
任何指向有效解决方案的指针都会受到高度赞赏。
发布于 2021-11-15 14:52:26
您可以为您的需求使用查询作业。负载作业习惯于从GCS存储桶或本地文件中摄取BigQuery中的数据。
查询作业的配额和限制可以找到这里。这些配额和限制适用于通过运行交互式查询、计划查询和使用jobs.query和查询类型的jobs.insert API方法提交的作业自动创建的查询作业。在一个项目中,每个用户每秒最多可以发出300个并发API请求。
使用jobs.insert方法的查询作业将异步执行。使用Python客户端库(如您所愿)可以实现同样的目标,如下所示。有关更多信息,请参阅此文档。
from google.cloud import bigquery
# Construct a BigQuery client object.
client = bigquery.Client()
# TODO(developer): Set table_id to the ID of the destination table.
# table_id = "your-project.your_dataset.your_table_name"
job_config = bigquery.QueryJobConfig(destination=table_id)
sql = """
SELECT corpus
FROM `bigquery-public-data.samples.shakespeare`
GROUP BY corpus;
"""
# Start the query, passing in the extra configuration.
query_job = client.query(sql, job_config=job_config) # Make an API request.
query_job.result() # Wait for the job to complete.
print("Query results loaded to the table {}".format(table_id))由于作业将同时运行,因此不需要实现显式多处理。
https://stackoverflow.com/questions/69954360
复制相似问题