005.hive: str_to_map使用案例 | ApacheCN(apache中文网)

原创
2015/11/12 17:49
阅读数 6K

ApacheCN | apache中文网

使用说明:

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF

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.

案例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

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部