Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Writing a Dynamic Union Query in BigQuery Using a List of Tables

Hello everyone,

I am looking for a solution to create a dynamic union query in BigQuery using a list of tables. I came across this helpful approach on Stack Overflow, which involves using JavaScript's const to store the list and then using map to build the query.

However, my situation is a bit different. Instead of using a JavaScript const to store the list, I would like to store the list of tables directly in a BigQuery table. The goal is that whenever a new table is inserted into this list table, the union query should automatically incorporate it without any manual intervention.

Could anyone please guide me on how to achieve this dynamic union query in BigQuery using a list of tables stored in another BigQuery table?

Thank you for your assistance!

3 2 7,380
2 REPLIES 2