如何在Hive SELECT查询中对表名称进行CASE?
我想做点什么 -
SELECT col1, col2
FROM
CASE ${PARAM}
WHEN 'val1' THEN table1
WHEN 'val2' THEN table2
答案 0 :(得分:1)
这是可能的。像这样重写你的查询:
SELECT col1, col2 FROM table1 WHERE '${PARAM}' = 'val1' --only one subquery will be executed
union all
SELECT col1, col2 FROM table2 WHERE '${PARAM}' = 'val2'