码迷,mamicode.com
首页 > 其他好文 > 详细

str_to_map使用案例

时间:2015-11-12 18:23:43      阅读:318      评论:0      收藏:0      [点我收藏+]

标签:

使用说明:

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

str_to_map使用案例

标签:

原文地址:http://my.oschina.net/repine/blog/529562

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!