当前位置: 首页 > wzjs >正文

大连电子学校网站建设哪个网站做外链视频好

大连电子学校网站建设,哪个网站做外链视频好,wordpress 连载插件,怎么做网站缩略图Hive查询之排序 文章目录 Hive查询之排序写在前面Hive查询之排序全局排序(Order By)按照别名排序多个列排序每个Reduce内部排序(Sort By)分区(Distribute By)Cluster By 写在前面 Linux版本:Ce…

Hive查询之排序


文章目录

  • Hive查询之排序
    • 写在前面
    • Hive查询之排序
      • 全局排序(Order By)
      • 按照别名排序
      • 多个列排序
      • 每个Reduce内部排序(Sort By)
      • 分区(Distribute By)
      • Cluster By


写在前面

  • Linux版本:CentOS7.5
  • Hive版本:Hive-3.1.2

Hive查询之排序

全局排序(Order By)

Order By:是 全局排序,只有 一个 Reducer
(1)使用 ORDER BY 子句排序

  • ASC(ascend): 升序(默认)

  • DESC(descend): 降序

(2)ORDER BY 子句在SELECT语句的结尾

(3)案例实操

  • 查询员工信息按工资升序排列
hive (default)> select * from emp order by sal;
  • 查询员工信息按工资降序排列
hive (default)> select * from emp order by sal desc;

按照别名排序

按照员工薪水的2倍排序

hive (default)> select ename, sal*2 twosal from emp order by twosal;

多个列排序

按照部门和工资联合字段进行升序排序

hive (default)> select ename, deptno, sal from emp order by deptno, sal ;

每个Reduce内部排序(Sort By)

  • Sort By:对于大规模的数据集order by的效率非常低。在很多情况下,并不需要全局排序,此时可以使用sort by。
  • Sort by为每个reducer产生一个排序文件。每个Reducer内部进行排序,对全局结果集来说不是排序。

设置reduce的个数

hive (default)> set mapreduce.job.reduces=3;

查看设置reduce的个数

hive (default)> set mapreduce.job.reduces;

根据部门编号降序查看员工的信息

hive (default)> select * from emp sort by deptno desc;

将查询的结果导入到文件中(按照部门编号降序排序)

hive (default)> insert overwrite local directory '/opt/module/hive/datas/sortby-result'select * from emp sort by deptno desc;

分区(Distribute By)

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

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

案例实操:

  • 先按照部门编号分区,再按照员工编号降序排序。
hive (default)> set mapreduce.job.reduces=3;
hive (default)> insert overwrite local directory '/opt/module/hive/datas/distribute-result' select * from emp distribute by deptno sort by empno desc;

注意:

  • distribute by的分区规则是根据分区字段的hash码与reduce的个数进行模除后,余数相同的分到一个区。
  • Hive要求DISTRIBUTE BY语句要写在SORT BY语句之前。

Cluster By

distribute bysort by 字段相同时,可以使用 cluster by 方式。

同时,我们要知道:cluster by除了具有distribute by的功能外还兼具sort by的功能。但是排序只能是升序排序,不能指定排序规则为ASC或者DESC。

以下两种写法等价

hive (default)> select * from emp cluster by deptno;
hive (default)> select * from emp distribute by deptno sort by deptno;

注意:按照部门编号分区,不一定就是固定死的数值,可以是20号和30号部门分到一个分区里面去。

全文结束!!!


文章转载自:

http://gIkr9RWz.hcgqd.cn
http://fTB1WNW9.hcgqd.cn
http://0wJx1XWD.hcgqd.cn
http://nSk5oRfT.hcgqd.cn
http://08EZmgAH.hcgqd.cn
http://nhGGB78i.hcgqd.cn
http://fQHI1S4G.hcgqd.cn
http://tOAofUW2.hcgqd.cn
http://G34SSs4U.hcgqd.cn
http://FpgIsNpL.hcgqd.cn
http://sukTKbDA.hcgqd.cn
http://K7qzNlg2.hcgqd.cn
http://ZP0OqBBo.hcgqd.cn
http://VYLMbvVH.hcgqd.cn
http://efFR6oDI.hcgqd.cn
http://DSsLX8Do.hcgqd.cn
http://HDiqEXJq.hcgqd.cn
http://BBXuRNWf.hcgqd.cn
http://anjs498p.hcgqd.cn
http://YP74L1U3.hcgqd.cn
http://0493Gl0B.hcgqd.cn
http://UIyXHSKi.hcgqd.cn
http://8jewoOIx.hcgqd.cn
http://PbT1HpIi.hcgqd.cn
http://DZPxhBIF.hcgqd.cn
http://IWlSCxET.hcgqd.cn
http://oJa0zsHO.hcgqd.cn
http://IWSNY8pP.hcgqd.cn
http://xjiRQcYZ.hcgqd.cn
http://z9FRZ9Ap.hcgqd.cn
http://www.dtcms.com/wzjs/735669.html

相关文章:

  • 清远做网站哪家好做安全防护信息的网站
  • 工程行业网站h5小游戏在线玩
  • 博客网站开发源代码优化方案英语答案
  • 千套模板快速自助建站消防工程师证怎么考
  • 苏州哪家做网站好wordpress相册效果
  • 如何做导购网站自己做的网站如何引流
  • 用html做网站源代码流量套餐汇总网站
  • 苏州建设工程质量监督站网站网站前置或专项审批
  • 趴比库的网站是谁建设的泰安高品质网站建设
  • 安平县护栏网站建设网站建设三秒原则
  • 网站平台建设费用的会计核算高水平的网站建设公司
  • 吉粤建设工程股份有限公司网站安阳建设局网站
  • 想让一个网站上线需要怎么做雅思培训班价格一览表
  • 网站页面布局模板wordPress如何设置
  • 可以做高清思维导图的网站深圳网站建设的特殊性
  • 上海网站建设上海网站制作双城网站
  • 网站建设与维护成绩查询个人信息服务平台登录
  • ps做汽车网站下载aso排名优化知识
  • 做餐饮如何加入外卖网站网页制作与网站建设试卷及答案
  • 域名建设好了怎么在建设网站企业网站的建立视频
  • 长春网站建设wordpress最强的教育网站
  • 双峰网站建设网站手机端跳转页面模板
  • 网站建设微信软文c2c网站开发毕业设计
  • 学校网站建设需求分析调研表网站名称 规则
  • 政务服务网站建设标准广州网站建设好评公司
  • 电子商务 网站建设最新发布的手机
  • 志愿者协会网站建设制作网站案例网址
  • 网站建设注册教程wordpress 巨慢
  • wordpress 修改网址导航网站seo快速优化
  • 网站登陆界面怎么做网站后台公告id修改