zoukankan      html  css  js  c++  java
  • Hive_分区排序(Distribute By)

    Distribute By: 在有些情况下,我们需要控制某个特定行应该到哪个reducer,通常是为了进行后续的聚集操作。distribute by子句可以做这件事。distribute by类似MR中partition(自定义分区),进行分区,结合sort by使用。

    对于distribute by进行测试,一定要分配多reduce进行处理,否则无法看到distribute by的效果。

    案例实操:

    (1)先按照部门编号分区,再按照员工编号降序排序。

    hive (default)> set mapreduce.job.reduces=3;
    hive (default)> insert overwrite local directory '/opt/module/datas/distribute-result' select * from emp distribute by deptno sort by empno desc;

    注意:

    1.distribute by的分区规则是根据分区字段的hash码与reduce的个数进行模除后,余数相同的分到一个区。

    2.Hive要求DISTRIBUTE BY语句要写在SORT BY语句之前。

    学习中,博客都是自己学习用的笔记,持续更新改正。。。
  • 相关阅读:
    8.2Solr API使用(Facet查询)
    8.1Solr API使用(分页,高亮)
    7.Solr查询参数
    6.Solr4.10.3API使用(CURD)
    5.Solr4.10.3中配置中文分词器
    3.Solr4.10.3目录结构
    2.Linux环境下配置Solr4.10.3
    1.Solr介绍
    java集合中List与set的区别
    js快速排序
  • 原文地址:https://www.cnblogs.com/Tunan-Ki/p/11808562.html
Copyright © 2011-2022 走看看