BigQuery加载作业不会插入所有数据

问题描述 投票:0回答:1

我有大约200k CSV(所有具有相同的架构)。我为他们编写了一个Cloud Function,将它们插入到BigQuery中,这样我只要将CSV复制到存储桶,就会执行该函数并将数据加载到BigQuery数据集中

我基本上使用了与文档中相同的代码。

dataset_id = 'my_dataset'  # replace with your dataset ID
table_id = 'my_table'  # replace with your table ID
table_ref = bigquery_client.dataset(dataset_id).table(table_id)
table = bigquery_client.get_table(table_ref)  # API request 

def bigquery_csv(data, context):

  job_config = bigquery.LoadJobConfig()
  job_config.write_disposition = bigquery.WriteDisposition.WRITE_APPEND
  job_config.skip_leading_rows = 1
  # The source format defaults to CSV, so the line below is optional.
  job_config.source_format = bigquery.SourceFormat.CSV

  uri = 'gs://{}/{}'.format(data['bucket'], data['name'])
  errors = bigquery_client.load_table_from_uri(uri,
                                    table_ref,
                                    job_config=job_config)  # API request

  logging.info(errors)
  #print('Starting job {}'.format(load_job.job_id))

  # load_job.result()  # Waits for table load to complete.
  logging.info('Job finished.')

  destination_table = bigquery_client.get_table(table_ref)
  logging.info('Loaded {} rows.'.format(destination_table.num_rows))

但是,当我将所有CSV复制到存储桶(大约43 TB)时,并非所有数据都添加到BigQuery中,并且只插入了大约500 GB。

我无法弄清楚什么是错的。堆栈驱动程序日志记录中未显示任何插入作业,并且复制作业完成后未运行任何功能。

google-cloud-platform google-bigquery google-cloud-functions
1个回答
0
投票

但是,当我将所有CSV复制到存储桶(大约43 TB)时,并非所有数据都添加到BigQuery中,并且只插入了大约500 GB。

您正在达到此link中定义的BigQuery负载限制

enter image description here

您应该将文件拆分为较小的文件,上传将起作用

© www.soinside.com 2019 - 2024. All rights reserved.