简体   繁体   English

大查询表将在本地计算机中提取为JSON

[英]Big Query table to be extracted as JSON in Local machine

I have an idea on how to extract Table data to Cloud storage using Bq extract command but I would like rather like to know, if there are any options to extract a Big Query table as NewLine Delimited JSON to Local Machine? 我对如何使用Bq extract命令将表数据提取到云存储中有一个想法,但是我想知道,是否有任何选项可以将大查询表作为NewLine分隔JSON提取到本地计算机?

I could extract Table data to GCS via CLI and also download JSON data from WEB UI but I am looking for solution using BQ CLI to download table data as JSON in Local machine?. 我可以通过CLI将表数据提取到GCS,也可以从WEB UI下载JSON数据,但是我正在寻找使用BQ CLI在本地计算机中以JSON格式下载表数据的解决方案。 I am wondering is that even possible? 我想知道这有可能吗?

You need to use Google Cloud Storage for your export job. 您需要将Google Cloud Storage用于导出作业。 Exporting data from BigQuery is explained here , check also the variants for different path syntaxes. 此处说明从BigQuery导出数据的方法,还请检查不同路径语法的变体。

Then you can download the files from GCS to your local storage. 然后,您可以将文件从GCS下载到本地存储中。

Gsutil tool can help you further to download the file from GCS to local machine. Gsutil工具可以帮助您进一步将文件从GCS下载到本地计算机。

You first need to export to GCS, then to transfer to local machine. 您首先需要导出到GCS,然后再传输到本地计算机。

If you use the BQ Cli tool, then you can set output format to JSON, and you can redirect to a file. 如果使用BQ Cli工具,则可以将输出格式设置为JSON,并且可以重定向到文件。 This way you can achieve some export locally, but it has certain other limits. 这样,您可以在本地实现某些导出,但是它还有其他一些限制。

this exports the first 1000 line as JSON 这会将前1000行导出为JSON

bq --format=prettyjson query --n=1000 "SELECT * from publicdata:samples.shakespeare" > export.json

It's possible to extract data without using GCS, directly to your local machine, using BQ CLI. 无需使用GCS,就可以使用BQ CLI将数据直接提取到本地计算机中。

Please see my other answer for details: BigQuery Table Data Export 请查看我的其他答案以获取详细信息: BigQuery表数据导出

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM