0
votes

If every query creates a temporary table, is it possible to find out the name of that temporary table in a subsequent SQL statement?

Per https://cloud.google.com/bigquery/querying-data :

All query results are saved to a table, which can be either persistent or temporary:

A temporary table is a randomly named table saved in a special dataset; The table has a lifetime of approximately 24 hours. Temporary tables are not available for sharing, and are not visible using any of the standard list or other table manipulation methods.

For example:

/* query 1 */
select * from whatever;

/* query 2 */
select * from [temporary_table_that_just_got_created];
1
I'm trying to develop some queries, using the Squirrel SQL interface. It would be convenient if I didn't have to drop into a shell to run these queries through the API.Emery Lapinski

1 Answers

2
votes

You cannot determine that name from within BigQuery Web UI using BigQuery SQL
But, Yes, you can find it by looking in Query History
You should find you query in history list and expand it by clicking on it
Name you are looking for is under "Destination Table"

It is also possible to do this with BigQuery API and very useful in client applications

You should use Jobs: get API and see configuration.query.destinationTable (https://cloud.google.com/bigquery/docs/reference/v2/jobs#resource)