I had a deep look on the internet, but I'm not able to find any suitable answer.
In hive, is it possible to declare a variable, lets say:
test = 1
And change the value of this variable inside a query?
select
case
when field > 1 then test = test+1
else test = 1
end as test
from my table
It is possible. Please find the below code to create a variable in Hive.
hive> SET cust_id = 1234567890;
Once you create variable you can use it in your query like below.
hive> select * from cust_table where customer_id = '${hiveconf:cust_id}';
Hope this will help you. Now you can apply this to your scenario.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With