I've tried to use nested variables directly in a hive query. I'm using Hive and Dbeaver.
My goal is to loop through a list of conditions and save the results in numbered tables (condition_1 | tbl_1, condition_2, tbl_2, etc) Here's an example:
@set condition_1 = col1 in (1,10,11) and col2 in (1000,10000)
@set condition_2 = col1 in (2,20,22) and col2 in (2000,20000)
@Set ctrl= 1
create table tbl_${ctrl}
select ${ctrl} as id, * from my_table where ${condition_${ctrl}}
When I run the select statement, it fails at where statement and resolves only ctrl variable and I get this error message:
SQL Error [40000] [42000]: Error while compiling statement: FAILED: ParseException line 22:6 cannot recognize input near '$' '{' 'condition_1' in expression specification
I think hive is ignoring the last closing curly bracket. Any help would be appreciated!
I read the Language Manual Variable Substitution but it only show this:
set a=1;
set b=a;
set c=${hiveconf:${hiveconf:b}};
set c;
--uses nested variables.