我想使用bigquery编写这样的查询,我的文件存储在Google云平台存储中:
select * from my_table where id in ('gs://bucket_name/file_name.csv')
我没有结果。可能吗?还是我错过了什么?
答案 0 :(得分:2)
您可以使用CLI或API对GCS文件执行临时查询,而无需创建表,此处Accessing external (federated) data sources with BigQuery’s data access layer
包含了完整的示例代码段在这里:
BigQuery query --external_table_definition=healthwatch::date:DATETIME,bpm:INTEGER,sleep:STRING,type:STRING@CSV=gs://healthwatch2/healthwatchdetail*.csv 'SELECT date,bpm,type FROM healthwatch WHERE type = "elevated" and bpm > 150;'
Waiting on BigQueryjob_r5770d3fba8d81732_00000162ad25a6b8_1 ... (0s)
Current status: DONE
+---------------------+-----+----------+
| date | bpm | type |
+---------------------+-----+----------+
| 2018-02-07T11:14:44 | 186 | elevated |
| 2018-02-07T11:14:49 | 184 | elevated |
+---------------------+-----+----------+
另一方面,您可以创建具有自动检测模式的permament EXTERNAL表,以促进WebUI和持久性在此处Querying Cloud Storage Data
上了解更多内容。