BigQuery table的模式可以在web UI updated中查看,也可以使用bq工具将其作为JSON文件来查看.然而,我找不到一种方法将这个模式从现有表转储到JSON文件(最好是从命令行).可能吗?

推荐答案

将模式从现有表转储到JSON文件的方法(最好是从命令行).可能吗?

试试下面

bq show bigquery-public-data:samples.wikipedia  

可以使用–format标志美化输出

--format: none|json|prettyjson|csv|sparse|pretty:

命令输出的格式.选项包括:

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.

Realized I provided partial answer :o)

下面是PO想要的

bq show --format=prettyjson bigquery-public-data:samples.wikipedia | jq '.schema.fields' 

Json相关问答推荐

Golang JSON Date Tim.Date()测试请求

如何在使用GO时检测JSON中不需要的字段?

如何在VegaLite中应用Times New Roman,CaliBiri字体

使用Jolt v.0.1.1向每个json元素添加一个键-值对

如何使用模式注册中心创建从主题中取消本地化的ks qlDB表?

Moshi:序列化 List 时出现问题

使用 jolt 变换压平具有公共列 JSON 的复杂嵌套

将JSON行转换为TSV格式, for each 数组项生成单独的行

shell解析json并循环输出组合变量

PowerShell:如何将哈希表输出为 json 并使用 foreach 循环将其存储在变量中?

如何使用 ConfigurationBuilder 解析现有的 json 字符串(不是文件)

从 JSON 对象中删除键值对

规范化 JSON 文件

如何使用 jq 将 JSON 对象流转换为数组

Jackson 中的 readValue 和 readTree:何时使用哪个?

对象序列化为 JSON(使用 Gson).如何在 UpperCamelCase 中设置字段名称?

Jackson 动态属性名称

杰克逊:反序列化 for each 值都具有正确类型的 Map

使用 Codable 序列化为 JSON 时的 Swift 字符串转义

为什么 jqXHR.responseText 返回字符串而不是 JSON 对象?