I want to run a sql query on multiple tables in a dataset in bigquery. I have the names of these tables in a list in my python script and I want to loop through that list and run the query on every table in the list.
My issue is that I cannot figure out how to structure my query to take python variables as inputs. For example, I have these variables in my script:
# Variables for testing
dataset_id = 'test_dataset'
table_id = 'test_table'
This is how I'm trying to use them in my query object:
query = """
SELECT *
FROM """ + dataset_id + '.' + table_id + """
ORDER BY 1 asc;
"""
This doesn't work and I can't find anything relevant on this online. I'd really appreciate it if you could help me structure this query correctly!