I am trying to use variables in my Hive script. But for some reason it isn't working.
SET $app_count=select max(app_id) from app_table;
SELECT '${hiveconf:app_count}',app_name,ROW_NUMBER() OVER (ORDER BY app_name) FROM new_apps;
Output
_c0 app_name _wcol0
app1 1
app2 2
app3 3
Expected result: lets say the max(app_id) from another table is 10
_c0 app_name _wcol0
10 app1 1
10 app2 2
10 app3 3
Not sure why the variable value is not substituting in the query. I even used the setting
'set hive.variable.substitute=true;' . But it didn't make any change. Thanks in Advance. Any alternate solution is also appreciated.
Just store the result of this query in another table(test) with single column app_id.
select max(app_id) from app_table
Then you can use the below query:
select test.app_id,new_apps.app_name,ROW_NUMBER() OVER (ORDER BY new_apps.app_name) FROM new_apps join test;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.