collect_all() hive 0.12 shell
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-CollectionFunctions
apache
hive如何將 spa
a b1
a b2
a b2
c d1
c d1
d d2 orm
變爲: string
a ["b1","b2","b2"]
c ["d1","d1"]
d ["d2"] it
test.txt (空格分隔) io
a b1
1.建表 table
drop table tmp_jzl_20151027_test;
create table tmp_jzl_20151027_test
(
col1 string,
col2 string
)
row format delimited
fields terminated by ' '
stored as textfile; form
load data local inpath '/home/jiangzl/shell/test.txt' into table tmp_jzl_20151027_test; test
2.處理
hive>
> select col1, collect_all(col2))
> from tmp_jzl_20151027_test
> group by col1;
a ["b1","b2","b2"]
c ["d1","d1"]
d ["d2"]
本文author:數據的開拓者成員之一 江中煉
QQ羣:248087140
座右銘:
你在你擅長的領域牛逼,
並帶着一羣小白變牛逼,
別人會發自心裏的去尊重你的。
--可點擊加入咱們