Bigquery Query to Find The Column Names of a Table

Bigquery query to find the column names of a table

Update: This is now possible! See the INFORMATION SCHEMA docs and the answers below.

Answer, circa 2012:

It's not currently possible to retrieve table metadata (i.e. column names and types) via a query, though this isn't the first time it's been requested.

Is there a reason you need to do this as a query? Table metadata is available via the tables API.

How to find all the column names of a table where the column names match a certain string? (BigQuery)

You need to run a query like

SELECT
column_name
FROM
`bigquery-public-data`.census_bureau_usa.INFORMATION_SCHEMA.COLUMNS
WHERE
column_name like '%age%' and table_name='population_by_zip_2000'

This returns:

Sample Image

Can we get Column Name from specific Table in Google BigQuery?

I got result using Java:

Tables tableRequest = bigquery.tables();
Table table = tableRequest.get(projectName,datasetName,tableName).execute();
List<TableFieldSchema> fields = table.getSchema().getFields();


Related Topics



Leave a reply



Submit