我正在尝试创建具有以下逻辑的蜂巢视图:
create view test.view as
select
distinct(
case
when substr(value_1, 1, 10) < "2016-01-01" then
regexp_extract(value_2,'(?i-sx:\|([1-9][0-9]{0,3}x[1-9][0-9]{0,3})\|)',1)
else
split(value_2, '\|')[5]
end
) as value_3
from test.table;
但是,当我运行此功能时,我会得到以下输出:
FAILED: ParseException line 128:2 cannot recognize input near 'distinct' '(' 'case' in select expression
有人知道我怎么能写这篇文章,以免出现错误吗?或告诉我为什么会发生这种情况?
distinct
不是函数。它应用于选定的所有列上,并生成 all 选定列的唯一组合。
尝试以下操作:
select distinct case
when substr(value_1, 1, 10) < "2016-01-01"
then regexp_extract(value_2, '(?i-sx:\|([1-9][0-9]{0,3}x[1-9][0-9]{0,3})\|)', 1)
else split(value_2, '\|') [5]
end as value_3
from test.table;
所以,这个:
select distinct (col), col2
与:
相同select distinct col, col2