google-bigquery

getting the description of a table using Google bigquery


I am new to bigquery. First thing, I would have liked to do the SQL equivalent of DESC using Google bigquery. I did:

DESC `paj.dw.MY_TABLE`;

But I get:

Statement not supported: DescribeStatement

There are mentions of INFORMATION_SCHEMA in beta version, but I get:

Syntax error: Unexpected identifier "INFORMATION_SCHEMA"

How do you do it yourself ? Thank you.


Solution

  • Take first table in public dataset for example:

    SELECT column_name, is_nullable, data_type
    FROM `bigquery-public-data.austin_311.INFORMATION_SCHEMA.COLUMNS`
    WHERE table_name="311_request"
    

    You get:

    +--------------------------+-------------+-----------+
    |       column_name        | is_nullable | data_type |
    +--------------------------+-------------+-----------+
    | unique_key               | YES         | STRING    |
    | complaint_type           | YES         | STRING    |
    | complaint_description    | YES         | STRING    |
    | owning_department        | YES         | STRING    |
    | source                   | YES         | STRING    |
    | status                   | YES         | STRING    |
    | status_change_date       | YES         | TIMESTAMP |
    | created_date             | YES         | TIMESTAMP |
    | last_update_date         | YES         | TIMESTAMP |
    | close_date               | YES         | TIMESTAMP |
    | incident_address         | YES         | STRING    |
    | street_number            | YES         | STRING    |
    | street_name              | YES         | STRING    |
    | city                     | YES         | STRING    |
    | incident_zip             | YES         | INT64     |
    | county                   | YES         | STRING    |
    | state_plane_x_coordinate | YES         | STRING    |
    | state_plane_y_coordinate | YES         | FLOAT64   |
    | latitude                 | YES         | FLOAT64   |
    | longitude                | YES         | FLOAT64   |
    | location                 | YES         | STRING    |
    | council_district_code    | YES         | INT64     |
    | map_page                 | YES         | STRING    |
    | map_tile                 | YES         | STRING    |
    +--------------------------+-------------+-----------+