Dynamically Querying Multiple Tables In BigQuery
Asked Answered
M

2

9

I have a BigQuery database where daily data is uploaded into it's own table. So I have tables named "20131201", "20131202", etc. I can write a fixed query to "merge" those tables by doing:

SELECT * FROM db.20131201, db.20131202, ...

I'd like to have a single query that does not require me to update the Custom SQL everytime a new table is added. Something like:

SELECT * FROM db.*

Which currently doesn't work. I would like to avoid making one giant table. Is there a work-around that I can do, or will this have to be a feature request?

End-goal is for a Tableau data connection to all the tables.

Marybellemarybeth answered 3/1, 2014 at 21:34 Comment(3)
this is an interesting feature request!Unbacked
Agreed, this would be an interesting feature! A concept of Views in BigQuery would allow to do that and would give a lot of flexibility.Undirected
In my experience selecting * in big query is bad, and it really slows down the process.Keil
N
3

This isn't exactly what you've asked for, but I've managed to use https://developers.google.com/bigquery/query-reference#tablewildcardfunctions in particular

TABLE_DATE_RANGE(prefix, timestamp1, timestamp2)

to achieve a similar result for use in tableaux. You'll still need to provide 2 date parameters, but it's substantially better than dynamically generating the FROM clause.

Hope this helps.

Nevermore answered 22/5, 2014 at 1:7 Comment(0)
F
0

As of now in google bigquery this dynamic Sql [like "EXECUTE SQL" in mssqlserver] is not avilable...sulry google will look inthis i belive :)

Forbiddance answered 19/4, 2014 at 22:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.