有没有一种方法可以将BigQuery表的架构导出为JSON? [英] Is there a way to export a BigQuery table's schema as JSON?
问题描述
BigQuery 表具有可在网络用户界面中查看的架构,已更新,或用于
A BigQuery table has schema which can be viewed in the web UI, updated, or used to load data with the bq
tool as a JSON file. However, I can't find a way to dump this schema from an existing table to a JSON file (preferably from the command-line). Is that possible?
推荐答案
一种将模式从现有表转储到JSON文件(最好从命令行)的方法.有可能吗?
a way to dump schema from an existing table to a JSON file (preferably from the command-line). Is that possible?
尝试以下
bq show bigquery-public-data:samples.wikipedia
您可以使用–format标志来美化输出
You can use –format flag to prettify output
-format:none | json | prettyjson | csv | sparse | pretty:
--format: none|json|prettyjson|csv|sparse|pretty:
命令输出的格式.选项包括:
Format for command output. Options include:
none: ...
pretty: formatted table output
sparse: simpler table output
prettyjson: easy-to-read JSON format
json: maximally compact JSON
csv: csv format with header
前三个旨在使人可读,后三个是 传递给另一个程序.如果未选择任何格式,则将选择一种格式 根据命令运行.
The first three are intended to be human-readable, and the latter three are for passing to another program. If no format is selected, one will be chosen based on the command run.
意识到我提供了部分答案:o)
Realized I provided partial answer :o)
以下是PO想要的
bq show --format=prettyjson bigquery-public-data:samples.wikipedia | jq '.schema.fields'
这篇关于有没有一种方法可以将BigQuery表的架构导出为JSON?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!