支持 BigQuery SQL 中的 UNION 函数 [英] Support UNION function in BigQuery SQL

查看:26
本文介绍了支持 BigQuery SQL 中的 UNION 函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

BigQuery 似乎还不支持 UNION:https://developers.google.com/bigquery/docs/query-reference

BigQuery does not seem to have support for UNION yet: https://developers.google.com/bigquery/docs/query-reference

(我的意思不是将源表合并在一起.它有.)

(I don't mean unioning tables together for the source. It has that.)

快到了吗?

推荐答案

如果你想要 UNION 以便你可以组合查询结果,你可以使用 subselects在 BigQuery 中:

If you want UNION so that you can combine query results, you can use subselects in 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

This is almost exactly equivalent to the 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 这将不起作用)

(note that if want SQL UNION and not UNION ALL this won't work)

或者,您可以运行两个查询并附加结果.

Alternately, you could run two queries and append the result.

这篇关于支持 BigQuery SQL 中的 UNION 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆