在hive中我们还有4个by函数,分别是:
order by sort by distribute by cluster by
下面我们分别介绍下这4个函数
1、order by
全局排序,只有一个Reducer。
2、sort by
分区内有序。
3、Distribute By
类似MR中Partition,进行分区,结合sort by使用。
4、cluster by
当Distribute by和Sorts by字段相同时,可以使用Cluster by方式。 Cluster by除了具有Distribute by的功能外还兼具Sort by的功能。 但是排序只能是升序排序,不能指定排序规则为ASC或者DESC。
备注:
在生产环境中Order By用的比较少,容易导致OOM。 在生产环境中Sort By+ Distrbute By用的多。
还没有评论,来说两句吧...