从文本文件运行查询 [英] Running Query from text file
问题描述
我试图从命令行运行一个大的查询查询,但因为我的查询很长,所以我把它写入了一个文本文件。查询从GUI开始工作,我正在覆盖已经存在的表
bq query --allow_large_results --replace - destination_table = me.Tbl_MyTable'cat query.txt`'
但是,我收到错误结果:
$ b
查询字符串错误:处理作业错误
'dev:bqjob_r_00000123456789456123_1':遇到
\ 'cat query.txt
\'在第1行第1列。
期待:EOF
- 我是否需要将整个文件路径放在.txt文件名中? (这似乎没有什么区别)
- 在文本文件中是否需要注意任何字符(例如\或引号)? >
- 我使用的是where子句和group by子句 - 这是一个问题吗?
代替 cat
,只需从文件中输入输入。该命令将是:
bq查询--allow_large_results --replace --destination_table = me.Tbl_MyTable< query.txt
这会发送 query.txt的内容
到 bq
工具。
I'm trying to run a big query query from the command line, but because my query is very long I've written it in a text file. The query works from the GUI and I'm overwriting a table that already exsists
bq query --allow_large_results --replace --destination_table=me.Tbl_MyTable '`cat query.txt`'
However, I'm getting error results:
Error in query string: Error processing job 'dev:bqjob_r_00000123456789456123_1': Encountered " "\'
cat query.txt
\' "" at line 1, column 1. Was expecting: EOF
- Do I need to put the entire file path in the .txt filename? (this doesn't seem to make a difference)
- Are there any characters I need to be careful with in the text file (e.g. "\" or quotation marks) ?
- I'm using where clauses and group by clauses - is that an issue?
Instead of cat
, just pipe the input from the file. The command would be:
bq query --allow_large_results --replace --destination_table=me.Tbl_MyTable < query.txt
This will send the contents of query.txt
to the bq
tool.
这篇关于从文本文件运行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!