有没有办法将 BigQuery 表的架构导出为 JSON? [英] Is there a way to export a BigQuery table's schema as JSON?

查看:20
本文介绍了有没有办法将 BigQuery 表的架构导出为 JSON?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

BigQuery 具有可在网络用户界面中查看的架构,已更新,或用于加载数据 使用 bq 工具作为 JSON 文件.但是,我找不到将此模式从现有表转储到 JSON 文件(最好从命令行)的方法.这可能吗?

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

--格式:无|json|prettyjson|csv|稀疏|漂亮:

--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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆