选择Impala中的stack()UDTF

问题描述 投票:0回答:1

在Hive中,我可以使用stack()UDTF这样采样数据:

with students as ( 
select stack(5,
1,'Vikrant',
2,'Abhishek',
3,'Ragesh',
4,'Valeriy',
5,'Swarna') as (id, name)
)

select * from students;

在Presto I can use values中相同。

如何使用multiple selects for each row and UNION ALL like in this answer在Impala EXCEPT中做到这一点?

impala
1个回答
0
投票

根据我的研究,Impala尚不支持表生成功能。很遗憾,Impala中没有堆栈,no lateral view explodeno UDTF are possible

所以,唯一的方法是这样:

with students as ( 
select 1 as id,'Vikrant'  as name union all
select 2 as id,'Abhishek' as name union all
select 3 as id,'Ragesh'   as name union all
select 4 as id,'Valeriy'  as name union all
select 5 as id,'Swarna'   as name
)

select * from students;
© www.soinside.com 2019 - 2024. All rights reserved.