【问题标题】:is there any metadata store like 'hive metastore' in BigQuery?BigQuery 中有像“hive metastore”这样的元数据存储吗?
【发布时间】:2018-09-20 02:22:14
【问题描述】:

我是 BigQuery 的新手。我只是想知道,BigQuery 中是否有类似 hive 元存储(关于所有表、列及其描述的元数据)之类的东西?

【问题讨论】:

    标签: hive google-bigquery hcatalog metastore


    【解决方案1】:

    BigQuery 提供了一些特殊表,其内容代表元数据,例如数据集中的表和视图列表。 “元表”是只读的。要访问有关数据集中表和视图的元数据,请在查询的 SELECT 语句中使用 __TABLES_SUMMARY__ 元表。您可以使用 BigQuery 网页界面、使用命令行工具的 bq 查询命令或调用 jobs.insert API 方法并配置查询作业来运行查询。

    另一个更详细的元表是 __TABLES__ - 请参见下面的示例

        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__`  
    

    对于表模式 - 列、描述 - 您可以使用 bq 命令行 - 例如:

    bq show publicdata:samples.shakespeare  
    

    结果为

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

    https://cloud.google.com/bigquery/bq-command-line-tool#gettable查看更多信息

    【讨论】:

    • 感谢 Mikhail 提供的宝贵信息。 BigQuery 是否会为此查询收费,因为它只是有关所有表信息的元数据,而不是遍历数据的行或列?
    猜你喜欢
    • 2020-03-01
    • 2017-05-16
    • 1970-01-01
    • 1970-01-01
    • 2016-04-17
    • 1970-01-01
    • 2021-08-19
    • 2017-09-13
    相关资源
    最近更新 更多