无法使用 bq.py cli 获得集群 table 定义

Unable to get clustered table definition using bq.py cli

我有一个 Google BigQuery 集群分区 table。我正在尝试使用 bq.py cli 工具获取 Google BigQuery 集群分区 table 定义。我得到 json 输出,但它没有聚类信息。

% bq version  

This is BigQuery CLI 2.0.69


% bq show \   
--schema \
--format=prettyjson \
 uk-kingdom-911:ld_cv_1_population.cv_performance_t1_agg3_auh_mvpart

 
[
  {
    "name": "hstamp",
    "type": "TIMESTAMP"
  },
  {
    "name": "account_id",
    "type": "INTEGER"
  },
 ....
.....
]

Json 输出没有聚类信息。不确定我在这里遗漏了什么。

那是因为您使用了 --schema 标志。 --schema 标志仅显示 table 的基本架构,仅此而已。删除该标志,您应该会看到所有内容:

> bq show --format=prettyjson example_ds.test_table
==========================================================
{
  "clustering": {
    "fields": [
      "second_col"
    ]
  },
  "creationTime": "1623325001027",
  "etag": "xxx",
  "id": "my-project:example_ds.test_table",
  "kind": "bigquery#table",
  "lastModifiedTime": "1623325001112",
  "location": "xxx",
  "numBytes": "0",
  "numLongTermBytes": "0",
  "numRows": "0",
  "schema": {
    "fields": [
      {
        "mode": "NULLABLE",
        "name": "first_col",
        "type": "DATE"
      },
      {
        "mode": "NULLABLE",
        "name": "second_col",
        "type": "INTEGER"
      }
    ]
  },
  "selfLink": "xxxx",
  "tableReference": {
    "datasetId": "example_ds",
    "projectId": "my-project",
    "tableId": "test_table"
  },
  "timePartitioning": {
    "type": "DAY"
  },
  "type": "TABLE"
}