0

Is there a way to export the output of multiple hive queries in the hive CLI to the shell script?

Currently, I have shell script wherein there are multiple hive queries which I fire:

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

This will run all the queries in a separate hive session which will cause it to wait for resources in yarn. Instead, I want to run them in the same hive session

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

and get the output passed to the shell script into VAR1, VAR2 & VAR3. Is it possible?

0

1 Answer 1

3

Try a sub query

select c1.*, c2.*, c3.* from 
(select count(*) from table1) c1, 
(select count(*) from table2) c2, 
(select count(*) from table3) c3;
Sign up to request clarification or add additional context in comments.

1 Comment

I am thinking to make use of what has been mentioned in this link: community.hortonworks.com/content/supportkb/151091/… Some of my subqueries are complex, hence it would be better to break them down.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.