在Big Query中查询多个表 [英] Querying multiple tables in Big Query

查看:87
本文介绍了在Big Query中查询多个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于无法在BigQuery中更新表格中的数据,并且仅支持追加机制,因此我决定每月创建一个新表格。因此,假设2012年的表格将是( tbl_012012 tbl_022012 tbl_032012 ... tbl_122012 )。每条记录将与日期 timestamp 一起存储为字符串。

现在,如果我的应用程序想从2012年1月( tbl_012012 )到2012年3月(<$ BigQuery API会通过单个SQL范围查询自动遍历所需的表,还是必须使用额外的应用程序代码编写多个SQL查询以检索每个查询结果,然后将它们聚合总之?

解决方案

一个SQL查询可以引用多个表。只需用FROM子句中的逗号分隔每个表即可查询所有提到的表。

As it is not possible to update data within a table in BigQuery, and supports only append mechanism, I have decided to create new tables on monthly basis. So suppose for year 2012 the tables would be (tbl_012012, tbl_022012, tbl_032012,...tbl_122012). Each record will be stored along with date timestamp as string.

Now, if my application wants to fetch records ranging from Jan 2012(tbl_012012) to March 2012(tbl_032012), will BigQuery API automatically traverse through the desired tables via single SQL range query or will I have to write multiple SQL queries with extra application code to retrieve each query result and then aggregate them altogether?

解决方案

One SQL query can reference multiple tables. Just separate each table with a comma in the FROM clause to query across all mentioned tables.

这篇关于在Big Query中查询多个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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