Search code examples
google-bigquery

Get columns of temporary table in BigQuery


In BigQuery one can obtain a list of columns using the columns view INFORMATION_SCHEMA. This is documented here. Unfortunately, this seems to contain only tables inside a dataset.

I need to get the available columns for a session-local table. If working with BigQuery sessions on can upload Parquet files into a temporary table by not providing a dataset. This is only documented in bq load --help for which I cannot find an online reference.

Such a temporary table is known only to the session, so the risk of name clashes is greatly reduced. Additionally, there is less need to remove the table after one is done, as it will vanish with the session. Therefore I really would like to continue to use session-local temporary tables.

However, I also need to find out the column list of the temporary table. Is there a way to do so?


Solution

  • Currently, getting the metadata or list of column names of the Temporary table using INFORMATION_SCHEMA is not supported in BigQuery, and also as of I know there is no other way to do that in the BigQuery. You can view the schema in the Query History in the BigQuery or through the logs.

    However, you can file a Feature Request on the issue tracker, if you are interested in the implementation of this feature.