google-bigquery - 向 BigQuery 表添加列描述?

标签 google-bigquery

需要为 BigQuery 表的每一列添加描述,似乎我可以手动完成,如何以编程方式完成?

最佳答案

正如 Adam 所提到的,您可以使用 API 上的 table PATCH 方法来更新架构列。另一种方法是使用 bq。

您可以先通过执行以下操作来获取架构:

1:获取JSON模式:

TABLE=publicdata:samples.shakespeare

bq show --format=prettyjson ${TABLE} > table.txt

然后将模式从 table.txt 复制到 schema.txt ......它看起来像:
[
  {
    "description": "A single unique word (where whitespace is the delimiter) extracted from a corpus.",
    "mode": "REQUIRED",
    "name": "word",
    "type": "STRING"
  },
  {
    "description": "The number of times this word appears in this corpus.",
    "mode": "REQUIRED",
    "name": "word_count",
    "type": "INTEGER"
  },
  ....
]

2:将描述字段设置为您想要的任何内容(如果不存在,请添加它)。

3:告诉 BigQuery 使用添加的列更新架构。请注意,schema.txt 必须包含完整的架构。
 bq update --schema schema.txt -t ${TABLE}

关于google-bigquery - 向 BigQuery 表添加列描述?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30007888/

相关文章:

google-bigquery - 如何在 BigQuery 加载时获取比通用 "Failed to parse JSON: No active field found.; ParsedString returned false; Could not parse value"更多的信息?

azure - 将数据从 Azure Data Lake 移动到 Big Query

google-bigquery - BigQuery 中跨多个数组列的高级 UNNEST

google-bigquery - GROUP BY 和 HAVING with ALIAS 的 Bigquery 错误

google-bigquery - 是否可以将服务帐户限制为特定的 Big Query 数据集?

google-bigquery - 导出 Bigquery 日志

youtube - 在BigQuery中获取视频标题

google-bigquery - 在bigquery中使用array_agg时如何删除重复行

sql - 在大查询中从宽到长 reshape (标准 SQL)

go - 无法让 golang 和包 bigquery 工作以加载到大查询