is there any metadata store like 'hive metasto

2019-02-15 16:58发布

I am new to BigQuery. I just want to know, whether do we have anything like hive metastore (metadata about all tables, columns and their description) in BigQuery?

1条回答
ら.Afraid
2楼-- · 2019-02-15 17:08

BigQuery offers some special tables whose contents represent metadata, such as the list of tables and views in a dataset. The "meta-tables" are read-only. To access metadata about the tables and views in a dataset, use the __TABLES_SUMMARY__ meta-table in a query's SELECT statement. You can run the query using the BigQuery web UI, using the command-line tool's bq query command, or by calling the jobs.insert API method and configuring a query job.

Another more detailed meta-table is __TABLES__ - see example below

    SELECT table_id,
        DATE(TIMESTAMP_MILLIS(creation_time)) AS creation_date,
        DATE(TIMESTAMP_MILLIS(last_modified_time)) AS last_modified_date,
        row_count,
        size_bytes,
        CASE
            WHEN type = 1 THEN 'table'
            WHEN type = 2 THEN 'view'
            WHEN type = 3 THEN 'external'
            ELSE '?'
        END AS type,
        TIMESTAMP_MILLIS(creation_time) AS creation_time,
        TIMESTAMP_MILLIS(last_modified_time) AS last_modified_time,
        dataset_id,
        project_id
    FROM `project.dataset.__TABLES__`  

for table schema - columns, description - you can utilize bq command line - for example:

bq show publicdata:samples.shakespeare  

with result as

 tableId      Last modified                  Schema
 ------------- ----------------- ------------------------------------
 shakespeare   01 Sep 13:46:28   |- word: string (required)
                                 |- word_count: integer (required)
                                 |- corpus: string (required)
                                 |- corpus_date: integer (required)

see more at https://cloud.google.com/bigquery/bq-command-line-tool#gettable

查看更多
登录 后发表回答