如何获取配置单元中复杂数据类型列的长度

z0qdvdin  于 2021-06-02  发布在  Hadoop
关注(0)|答案(1)|浏览(370)

我有一个配置单元表包含类型为的列 array 以及 map 我想过滤数组/Map列包含n个以上元素的记录,怎么做?
ddl地址:

create table test (id string, v1 array<int>, v2 map<string,string>)

查询:

select * from test where length(v1)>10 or length(v2)>10
imzjd6km

imzjd6km1#

select * from test where size(v1)>10 or size(v2)>10

演示

create table test (id string, v1 array<int>, v2 map<string,string>);
insert into test select 1,array(1,2,3,4,5),map('K1','V1','K2','V2','K3','V3');
select  size(v1),size(v2)
from    test
;
+----+----+
| c0 | c1 |
+----+----+
|  5 |  3 |
+----+----+

相关问题