mysql collect_set_hive列转行 (collect_set())
一、問(wèn)題
hive如何將
a?????? b?????? 1
a?????? b?????? 2
a?????? b?????? 3
c?????? d?????? 4
c?????? d?????? 5
c?????? d?????? 6
變?yōu)?#xff1a;
a?????? b?????? 1,2,3
c?????? d?????? 4,5,6
二、數(shù)據(jù)
test.txt
a?????? b?????? 1
a?????? b?????? 2
a?????? b?????? 3
c?????? d?????? 4
c?????? d?????? 5
c?????? d?????? 6
三、答案
1.建表
drop table tmp_jiangzl_test;
create table tmp_jiangzl_test
(
col1 string,
col2 string,
col3 string
)
row format delimited fields terminated by '\t'
stored as textfile;
load data local inpath '/home/jiangzl/shell/test.txt' into table tmp_jiangzl_test;
2.處理
select col1,col2,concat_ws(',',collect_set(col3))
from tmp_jiangzl_test
group by col1,col2;
四、關(guān)于我們
本文author:數(shù)據(jù)的開(kāi)拓者成員之一 江中煉
QQ群:248087140
座右銘:
你在你擅長(zhǎng)的領(lǐng)域牛逼,
并帶著一群小白變牛逼,
別人會(huì)發(fā)自內(nèi)心的去尊重你的。
--可點(diǎn)擊加入我們
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的mysql collect_set_hive列转行 (collect_set())的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: win10笔记本设置账户密码忘了怎么办
- 下一篇: 大汉丽华秀酒多少钱42度?