Google Bigquery BQ命令行从文件执行查询 [英] Google Bigquery BQ command line execute query from a file

查看:275
本文介绍了Google Bigquery BQ命令行从文件执行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用bq命令行工具运行查询,e,g:bq查询select * from table,如果将查询存储在文件中并从该文件运行查询,该怎么办?有没有办法做到这一点?

I use bq command line tool to run queries, e,g: bq query "select * from table", what if I store the query in a file and run the query from that file? is there a way to do that?

推荐答案

你可以从一个文本文件中运行一个查询,

You can run a query from a text file with a little bit of shell magic:

$ echo "SELECT 17" > qq.txt
$ bq query "$(cat qq.txt)"

Waiting on bqjob_r603d91b7e0435a0f_00000150c56689c6_1 ... (0s) Current status: DONE   
+-----+
| f0_ |
+-----+
|  17 |
+-----+

注意这适用于任何unix版本(包括mac )。如果您使用的是Windows,则应该在PowerShell下运行,但不能使用默认的cmd提示符。

Note this works on any unix variant (including mac). If you're using a windows, this should work under powershell but not the default cmd prompt.

这篇关于Google Bigquery BQ命令行从文件执行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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