Rah*_*rma 3 hadoop hive apache-spark-sql
我有一个蜂巢表包含类型的列array和map我想要筛选,其中阵列/图列包含超过记录ň元素,如何做到这一点?
DDL:
create table test (id string, v1 array<int>, v2 map<string,string>)
Run Code Online (Sandbox Code Playgroud)
查询:
select * from test where length(v1)>10 or length(v2)>10
Run Code Online (Sandbox Code Playgroud)
select * from test where size(v1)>10 or size(v2)>10
Run Code Online (Sandbox Code Playgroud)
演示
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');
Run Code Online (Sandbox Code Playgroud)
select size(v1),size(v2)
from test
;
Run Code Online (Sandbox Code Playgroud)
+----+----+
| c0 | c1 |
+----+----+
| 5 | 3 |
+----+----+
Run Code Online (Sandbox Code Playgroud)