将同一配置单元会话中的多个查询输出导出到shell脚本?

oknrviil  于 2021-06-01  发布在  Hadoop
关注(0)|答案(1)|浏览(350)

有没有办法将配置单元cli中多个配置单元查询的输出导出到shell脚本?
目前,我有一个shell脚本,其中有多个我启动的配置单元查询:

VAR1=`hive -e "select count(*) from table1;"`
VAR2=`hive -e "select count(*) from table2;"`
VAR3=`hive -e "select count(*) from table3;"`

这将在一个单独的配置单元会话中运行所有查询,这将导致它等待配置单元中的资源。相反,我希望在同一个配置单元会话中运行它们

`hive -e "select count(*) from table1;select count(*) from table2;select count(*) from table3;"`

并将传递给shell脚本的输出转换为var1、var2和var3。有可能吗?

sycxhyv7

sycxhyv71#

尝试子查询

select c1.*, c2.*, c3.* from 
(select count(*) from table1) c1, 
(select count(*) from table2) c2, 
(select count(*) from table3) c3;

相关问题