google-cloud-platform - 使用 bq CLI 在 bigquery 中列出数据集中的所有表并将它们存储到谷歌云存储

标签 google-cloud-platform google-bigquery gcloud-cli

我在一个数据集中有大约 108 个表。我正在尝试使用以下 bash 脚本提取所有这些表:

# get list of tables
tables=$(bq ls "$project:$dataset" | awk '{print $1}' | tail +3)

# extract into storage
for table in $tables
do
    bq extract --destination_format "NEWLINE_DELIMITED_JSON" --compression "GZIP" "$project:$dataset.$table" "gs://$bucket/$dataset/$table.json.gz" 
done

但似乎 bq ls 一次只能显示大约 50 个表,因此我无法将它们提取到云存储中。

无论如何我可以使用 bq ls 命令访问所有 108 个表吗?

最佳答案

列出 bq ls 将显示的表时的默认行数是 100。您可以使用命令行选项 --max_results-n 更改此值。

您还可以在 bq 中设置 $HOME/.bigqueryrc 的默认值。

Adding flags to .bigqueryrc

关于google-cloud-platform - 使用 bq CLI 在 bigquery 中列出数据集中的所有表并将它们存储到谷歌云存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54208253/

相关文章:

javascript - 在 Google App Engine 上重命名 index.html

google-cloud-platform - 有没有办法使用 Terraform 将具有 "owner role"(角色/所有者)的新用户添加到谷歌云项目?

mysql - 是否可以在 Google BigQuery 中聚合时运行计算

r - 通过 R Studio Server 使用 BigQuery 在 Google Compute Engine 上验证服务帐户

google-cloud-storage - 如何调试谷歌云存储的访问控制问题?

google-bigquery - 使用通配符删除 BigQuery 表

google-bigquery - 从基于用户的配置文件更新

google-cloud-platform - 通过服务帐户使用 Google Cloud Source Repositories

google-compute-engine - 如何更改 gcloud 中的事件配置文件?

github - 如何为多个 Google Cloud Functions 设置一个 GitHub 存储库?