【发布时间】:2018-04-18 11:26:36
【问题描述】:
刚刚在 StackOverflow 上发帖。
使用 google.cloud.bigquery python SDK,我一直在尝试制定一种解决方案,在不定义表架构的情况下将数据从 GCS 加载到 BigQuery。
我的 LoadJobConfig 的自动检测设置为 True,并且我在 GCS URI 中使用通配符 (*)。
我已经确认 Autodetect 可以使用通配符,但加载作业失败,因为我正在使用的数据源通常会自动检测特定列为浮点数(例如 0.30),但有时会添加运算符符号(例如
任何人都可以在无需定义架构的情况下想出解决方案吗?这是我传递给bigquery.client.Client 的load_table_from_uri 方法的LoadJobConfig。
source_uri = 'gs://%s/%s/%s/*' % (source, report_type, date)
job_config = bigquery.LoadJobConfig()
job_config.create_disposition = 'CREATE_IF_NEEDED'
job_config.skip_leading_rows = 1
job_config.source_format = 'CSV'
job_config.write_disposition = 'WRITE_TRUNCATE'
job_config.autodetect = True
job = bigquery_client.load_table_from_uri(source_uri, table_ref, job_config=job_config)
job.result()
【问题讨论】:
标签: python google-bigquery google-cloud-platform