据我所知,不支持table wildcard functions
目前在dplyr 和bigrquery 中。如果您不害怕丑陋的黑客攻击,您可以提取和编辑 dplyr 构建并发送到 bq 的查询,以便它指向多个表,而不仅仅是一个。
设置您的结算信息并连接到 BigQuery:
my_billing <- ##########
bq_db <- src_bigquery(
project = "bigquery-public-data",
dataset = "noaa_gsod",
billing = my_billing
)
gsod <- tbl(bq_db, "gsod1929")
如何从一张表中选择(仅供比较):
gsod %>%
filter(stn == "030750") %>%
select(year, mo, da, temp) %>%
collect
Source: local data frame [92 x 4]
year mo da temp
(chr) (chr) (chr) (dbl)
1 1929 10 01 45.2
2 1929 10 02 49.2
3 1929 10 03 48.2
4 1929 10 04 43.5
5 1929 10 05 42.0
6 1929 10 06 51.0
7 1929 10 07 48.0
8 1929 10 08 43.7
9 1929 10 09 45.1
10 1929 10 10 51.3
.. ... ... ... ...
如何通过手动编辑dplyr生成的查询从多个表中进行选择:
multi_query <- gsod %>%
filter(stn == "030750") %>%
select(year, mo, da, temp) %>%
dplyr:::build_query(.)
multi_tables <- paste("[bigquery-public-data:noaa_gsod.gsod", c(1929, 1930), "]",
sep = "", collapse = ", ")
query_exec(
query = gsub("\\[gsod1929\\]", multi_tables, multi_query$sql),
project = my_billing
) %>% tbl_df
Source: local data frame [449 x 4]
year mo da temp
(chr) (chr) (chr) (dbl)
1 1930 06 11 51.8
2 1930 05 20 46.8
3 1930 05 21 48.5
4 1930 07 04 56.0
5 1930 08 08 54.5
6 1930 06 06 52.0
7 1930 01 14 36.8
8 1930 01 27 32.9
9 1930 02 08 35.6
10 1930 02 11 38.5
.. ... ... ... ...
结果验证:
table(.Last.value$year)
1929 1930
92 357