Per quanto ne so non c'è alcun supporto per table wildcard functions in dplyr
e bigrquery
al momento. Se non temi i brutti hack puoi comunque estrarre e modificare la query che dplyr
costruisce e invia a bq
in modo che punti a diverse tabelle invece di una sola.
Impostare le informazioni di fatturazione e connettersi al BigQuery:
my_billing <- ##########
bq_db <- src_bigquery(
project = "bigquery-public-data",
dataset = "noaa_gsod",
billing = my_billing
)
gsod <- tbl(bq_db, "gsod1929")
Come selezionare da una tabella (solo per il confronto):
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
.. ... ... ... ...
Come selezionare da più tabelle da manualmente modifica della query generata da 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
.. ... ... ... ...
Convalida dei risultati:
table(.Last.value$year)
1929 1930
92 357