【发布时间】:2021-06-06 12:22:37
【问题描述】:
我尝试在配置单元查询中直接使用嵌套变量。我正在使用 Hive 和 Dbeaver。
我的目标是遍历条件列表并将结果保存在编号表中(condition_1 | tbl_1、condition_2、tbl_2 等) 这是一个例子:
@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}}
当我运行 select 语句时,它在 where 语句处失败并且仅解析 ctrl 变量,我收到以下错误消息:
SQL Error [40000] [42000]: Error while compiling statement: FAILED: ParseException line 22:6 cannot recognize input near '$' '{' 'condition_1' in expression specification
我认为 hive 忽略了最后一个右大括号。 任何帮助将不胜感激!
我阅读了Language Manual Variable Substitution,但它只显示:
set a=1;
set b=a;
set c=${hiveconf:${hiveconf:b}};
set c;
--uses nested variables.
【问题讨论】:
标签: variables hive hiveql dbeaver