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

标签 hadoop hive apache-spark-sql

我有一个配置单元表包含 arraymap 类型的列,我想过滤记录,其中 array/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

最佳答案

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 |
+----+----+

关于hadoop - 如何在配置单元中获取复杂数据类型列的长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44036382/

相关文章:

multithreading - Hadoop的Mapper对象是跨线程共享的吗?

hadoop - 如何使用 Hortonworks hdp SSH 客户端释放非 DFS 已用空间?

hadoop - 为什么这个简单的 Hive 表声明有效?仿佛变魔术

sql - 加载到 Hive 表中仅将整个数据导入第一列

scala - 如何重命名 Scala 中 count() 函数生成的列

apache-spark - 按时间戳分区好还是按年月日小时分区好

hadoop - 在 Impala 中将 STRING 转换为 DATE。 (可能的错误)

hadoop - Hive 当前日期函数

postgresql - hive 流式传输不起作用

java - 如何过滤 Spark/DataFrame 上不可为空的行