如何在枚举中使用枚举类型作为映射键

时间:2015-03-13 00:29:14

标签: hive thrift hiveql

在Hive中,我们使用thrift serdes(序列化/反序列化器)存储复杂的数据类型。

举个例子:

> describe foo.a_map;
a_map   map<AnEnumType,string>  from deserializer

我们可以使用Cascading访问这些内容,但我想使用Hive。

如果我尝试使用整数(枚举类型映射到的),Hive会咆哮。

select foo.a_map[0] from foo limit 10;
FAILED: SemanticException [Error 10032]: Line 2:7 MAP key type does not match index expression type '0'

想法?

1 个答案:

答案 0 :(得分:1)

我最终爆炸了地图,横向视图,然后转换为字符串并匹配字符串。像

这样的东西
select key1, value1
from foo
lateral view explode(a_map) foo_table as key1, value1
where cast(key1 as string) = '0'
相关问题