is there any metadata store like 'hive metastore' in BigQuery?

主宰稳场 提交于 2019-11-30 18:32:29

问题


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:


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



来源:https://stackoverflow.com/questions/48674811/is-there-any-metadata-store-like-hive-metastore-in-bigquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!