成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

hive如何實(shí)現(xiàn)行轉(zhuǎn)列

這篇文章主要介紹hive如何實(shí)現(xiàn)行轉(zhuǎn)列,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站制作、成都做網(wǎng)站、外貿(mào)營(yíng)銷(xiāo)網(wǎng)站建設(shè)、祿勸網(wǎng)絡(luò)推廣、微信小程序、祿勸網(wǎng)絡(luò)營(yíng)銷(xiāo)、祿勸企業(yè)策劃、祿勸品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供祿勸建站搭建服務(wù),24小時(shí)服務(wù)熱線:028-86922220,官方網(wǎng)址:jinyejixie.com

1。問(wèn)題

hive如何將

a       b       1,2,3

c       d       4,5,6

變?yōu)椋?/p>

a       b       1

a       b       2

a       b       3

c       d       4

c       d       5

c       d       6 

答案如下:

2。原始數(shù)據(jù):

test.txt

a b 1,2,3

c d 4,5,6

3。解決方法

方案1:

drop table test_jzl_20140701_test;

create table test_jzl_20140701_test

(

col1 string,

col2 string,

col3 string

)

row format delimited fields terminated by ' '

stored as textfile;

load data local inpath '/home/jiangzl/shell/test.txt' into table test_jzl_20140701_test;

select * from test_jzl_20140701_test  

a       b       1,2,3

c       d       4,5,6

遍歷數(shù)組中的每一列

select col1,col2,name 

from test_jzl_20140701_test  

lateral view explode(split(col3,',')) col3 as name;

a       b       1

a       b       2

a       b       3

c       d       4

c       d       5

c       d       6 

方案2:

drop table test_jzl_20140701_test1;

create table test_jzl_20140701_test1

(

col1 string,

col2 string,

col3 array<int>

)

row format delimited 

fields terminated by ' '

collection items terminated by ','   //定義數(shù)組的分隔符

stored as textfile;

load data local inpath '/home/jiangzl/shell/test.txt' into table test_jzl_20140701_test1;

select * from test_jzl_20140701_test1; 

a       b       [1,2,3]

c       d       [4,5,6]

遍歷數(shù)組中的每一列

select col1,col2,name 

from test_jzl_20140701_test1  

lateral view explode(col3) col3 as name;

a       b       1

a       b       2

a       b       3

c       d       4

c       d       5

c       d       6

4。補(bǔ)充知識(shí)點(diǎn):

select * from test_jzl_20140701_test; 

a       b       1,2,3

c       d       4,5,6

select t.list[0],t.list[1],t.list[2] from (

select (split(col3,',')) list from test_jzl_20140701_test)t;

OK

1       2       3

4       5       6

--查看數(shù)組長(zhǎng)度

select size(split(col3,',')) list from test_jzl_20140701_test;

3

3

以上是“hive如何實(shí)現(xiàn)行轉(zhuǎn)列”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

網(wǎng)站標(biāo)題:hive如何實(shí)現(xiàn)行轉(zhuǎn)列
標(biāo)題網(wǎng)址:http://jinyejixie.com/article32/ppjhpc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、軟件開(kāi)發(fā)、網(wǎng)站設(shè)計(jì)、動(dòng)態(tài)網(wǎng)站、標(biāo)簽優(yōu)化搜索引擎優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司
准格尔旗| 泌阳县| 千阳县| 禹城市| 凤凰县| 哈巴河县| 洪湖市| 彭山县| 贡嘎县| 丹寨县| 潞西市| 囊谦县| 云阳县| 卢氏县| 焉耆| 河池市| 武汉市| 抚顺县| 工布江达县| 普安县| 修武县| 兴海县| 漳平市| 眉山市| 司法| 庄河市| 来凤县| 浑源县| 泗水县| 道孚县| 楚雄市| 天门市| 汝州市| 厦门市| 五莲县| 库伦旗| 阜城县| 昭苏县| 景洪市| 莆田市| 综艺|