BigQuery似乎没有对UNION的支持:
https://developers.google.com/bigquery/docs/query-reference
https://developers.google.com/bigquery/docs/query-reference
(我不是表示将来的表合并在一起,它有.)
即将来临吗
解决方法
如果您希望UNION可以组合查询结果,则可以使用子选择
在BigQuery中:
在BigQuery中:
SELECT foo,bar FROM (SELECT integer(id) AS foo,string(title) AS bar FROM publicdata:samples.wikipedia limit 10),(SELECT integer(year) AS foo,string(state) AS bar FROM publicdata:samples.natality limit 10);
这几乎完全相当于sql
SELECT id AS foo,title AS bar FROM publicdata:samples.wikipedia limit 10 UNION ALL SELECT year AS foo,state AS bar FROM publicdata:samples.natality limit 10;
(注意,如果想要sql UNION而不是UNION ALL,这将不起作用)
或者,您可以运行两个查询并追加结果.