Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Io redirection 如何随查询一起输出Impala查询的结果_Io Redirection_Impala - Fatal编程技术网

Io redirection 如何随查询一起输出Impala查询的结果

Io redirection 如何随查询一起输出Impala查询的结果,io-redirection,impala,Io Redirection,Impala,有没有一种方法可以将Impala查询的结果与查询一起输出 例如,如果我的查询是'show databases',我希望将结果输出到一个类似以下内容的文件中: Query: show databases Result: ------default------- 当我运行impalashell-I someip-f'filename'-o'output'时,我只能一个接一个地看到结果,因此很难将哪个结果与哪个查询关联起来(特别是当输入文件包含大量查询时)。将stderr和stdout重定向到文件

有没有一种方法可以将Impala查询的结果与查询一起输出

例如,如果我的查询是
'show databases'
,我希望将结果输出到一个类似以下内容的文件中:

Query: show databases
Result: ------default-------

当我运行impalashell-I someip-f'filename'-o'output'时,我只能一个接一个地看到结果,因此很难将哪个结果与哪个查询关联起来(特别是当输入文件包含大量查询时)。

将stderr和stdout重定向到文件
(查询在stderr中)


演示

impala-shell -f 'filename' &>'output'
[cloudera@quickstart ~]$ cat>filename
select 1;
select 2;
select 3;
[cloudera@quickstart ~]$ impala-shell -f 'filename' &>'output'
[cloudera@quickstart ~]$ cat output 
Starting Impala Shell without Kerberos authentication
Connected to quickstart.cloudera:21000
Server version: impalad version 2.5.0-cdh5.7.0 RELEASE (build ad3f5adabedf56fe6bd9eea39147c067cc552703)
Query: select 1
+---+
| 1 |
+---+
| 1 |
+---+
Fetched 1 row(s) in 0.16s
Query: select 2
+---+
| 2 |
+---+
| 2 |
+---+
Fetched 1 row(s) in 0.02s
Query: select 3
+---+
| 3 |
+---+
| 3 |
+---+
Fetched 1 row(s) in 0.02s
[cloudera@quickstart ~]$