我使用str_to_map作为:-
hive> select str_to_map("A:1,B:1,C:1");
OK
{"C":"1","A":"1","B":"1"}
正如您所注意到的,它返回的对象类型为map < string,string>。我想要映射类型的对象。有什么出路吗?我们能以某种方式将其转换为map<字符串吗,int>?
发布于 2019-03-01 10:26:32
我盯着它看了一会儿,没有看到太多东西,但事实证明它很简单--只需使用cast
select cast(str_to_map("A:1,B:1,C:1") as map<string, int>)
-- {'A': 1, 'B': 1, 'C': 1}
发布于 2020-12-10 21:30:05
您可以尝试使用map_remove_keys UDF:
> add jar hdfs:///lib/brickhouse-0.7.1-SNAPSHOT.jar;
> create temporary function map_remove_keys as 'brickhouse.udf.collect.MapRemoveKeysUDF';
> select map_remove_keys(map("", 0), array(""));
+------+
| _c0 |
+------+
| {} |
+------+
https://stackoverflow.com/questions/38537382
复制相似问题