问题描述
我是 BigQuery 的新手.我只想知道,BigQuery 中是否有类似 hive Metastore(所有表、列及其描述的元数据)之类的东西?
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?
推荐答案
BigQuery 提供了一些特殊的表格,其内容代表元数据,例如数据集中的表格和视图列表.元表"是只读的.要访问有关数据集中表和视图的元数据,请在查询的 SELECT 语句中使用 __TABLES_SUMMARY__ 元表.您可以使用 BigQuery 网页界面、命令行工具的 bq 查询命令或通过调用 jobs.insert API 方法并配置查询作业来运行查询.
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.
另一个更详细的元表是 __TABLES__ - 请参见下面的示例
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__`
对于表架构 - 列,描述 - 您可以使用 bq 命令行 - 例如:
for table schema - columns, description - you can utilize bq command line - for example:
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-命令行工具#gettable
这篇关于BigQuery 中是否有像“hive Metastore"这样的元数据存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!