Storing Query result in a hive variable


#1

Hello Folks,

Can we store the result of a sql query in to a hive variable? I am trying to come up with a HQL code where I need to calculate the max(local_date) from a table and store it in a hive variable for later use in a WHERE clause or for any other need.

Please suggest a way to store the result of a query into a hive variable.

Regards,
Sree


#2

We can use a shell or python command to do that.
In shell use command similar to var='hive -S -e “query”'
and later when using the variable in the code you can use $var to access it. As it will be stored as an environment variable.