Hive高級(jí)查詢(group by、 order by、 join等) - 琴弦上、漫步 - 博客頻道 - CSDN.NET
http://blog.csdn.net/scgaliguodong123_/article/details/46944519
離線技術(shù)處理總結(jié) - 簡(jiǎn)書
http://www.itdecent.cn/p/257907195f3e
hive 中 Order by, Sort by ,Dristribute by,Cluster By 的作用和對(duì)比
order by
按照某些字段排序樣例
select col1,other...from tablewhere conditioorder by col1,col2 [asc|desc]
注意order by后面可以有多列進(jìn)行排序,默認(rèn)按字典排序order by為全局排序order by需要reduce操作,且只有一個(gè)reduce,與配置無(wú)關(guān)。數(shù)據(jù)量很大時(shí),慎用。
Sort排序
sort by col – 按照col列把數(shù)據(jù)排序
select col1,col2 from Mdistribute by col1sort by col1 asc,col2 desc
兩者結(jié)合出現(xiàn),確保每個(gè)reduce的輸出都是有序的。
distribute by與group by對(duì)比
都是按key值劃分?jǐn)?shù)據(jù)都使用reduce操作唯一不同的是distribute by只是單純的分散數(shù)據(jù),而group by把相同key的數(shù)據(jù)聚集到一起,后續(xù)必須是聚合操作。
order by與sort by 對(duì)比
order by是全局排序sort by只是確保每個(gè)reduce上面輸出的數(shù)據(jù)有序。如果只有一個(gè)reduce時(shí),和order by作用一樣。
cluster by
把有相同值的數(shù)據(jù)聚集到一起,并排序。效果等價(jià)于distribute by col sort by colcluster by col <==> distribute by col sort by col
文/MichaelFly(簡(jiǎn)書作者)原文鏈接:http://www.itdecent.cn/p/257907195f3e著作權(quán)歸作者所有,轉(zhuǎn)載請(qǐng)聯(lián)系作者獲得授權(quán),并標(biāo)注“簡(jiǎn)書作者”。