I have a hive table contains columns of type array and map and I want to filter record where array/map column contains more than N elements, how to do that?
DDL:
create table test (id string, v1 array<int>, v2 map<string,string>)
Query:
select * from test where length(v1)>10 or length(v2)>10
select * from test where size(v1)>10 or size(v2)>10
Demo
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 |
+----+----+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With