str_to_map hive 字符串转为map格式

map<string,string>

str_to_map(text[, delimiter1, delimiter2])

Splits text into key-value pairs using two delimiters. Delimiter1 separates text into K-V pairs, and Delimiter2 splits each K-V pair. Default delimiters are ',' for delimiter1 and '=' for delimiter2.

英语翻译如下:

使用两个分隔符将文本拆分为键值对。 Delimiter1将文本分成K-V对,Delimiter2分割每个K-V对。对于delimiter1默认分隔符是',',对于delimiter2默认分隔符是'='。

案例1:

hive> 

    > select str_to_map('aaa:11&bbb:22', '&', ':')
    > from tmp.tmp_jzl_20140725_test11;
OK

{"bbb":"22","aaa":"11"}

案例2:

hive> select str_to_map('aaa:11&bbb:22', '&', ':')['aaa']
    > from tmp.tmp_jzl_20140725_test11;

OK
11

展开阅读全文

没有更多推荐了,返回首页