How to use variables in HIVE Query

While working on HIVE, you may want to use variables in the query to get results. A good coding practice is not to hardcode values in the query itself so we should know how to use variables in the HIVE query. Hive variables can be referred using "hivevar" keyword.
We can set value of HIVE variable using below command:


We can use this value by using ${hivevar:VARIABLE_NAME} in the query.

set hivevar:desc='Legislators';
select * from sample_07 where description=${hivevar:desc};

Leave a Reply

Your email address will not be published. Required fields are marked *