
Hive函数
文章平均质量分 70
函数
奈何@
Instead of admitting that the truth of "let it be" is to readily accept any kind of outcome after making full efforts rather than to do nothing at the every beginning. We would rather take "Let it be" as an excuse to evade the path of throns in our life.
展开
-
窗口函数:LAG、LEAD、FIRST_VALUE、LAST_VALUE
窗口函数:LAG、LEAD、FIRST_VALUE、LAST_VALUE FIRST_VALUE 功能:取每个分区内某列的第一个值 语法:FIRST_VALUE(col) over (partition by col1 order by col2) 示例: –取每个部门薪资最高的员工编号 select empno, ename, salary, deptno, FIRST_VALUE(ename) over (partition by deptno order by salary desc) as firs原创 2021-04-26 10:51:35 · 548 阅读 · 0 评论 -
窗口函数:SUM、AVG、COUNT、MAX、MIN
窗口函数:SUM、AVG、COUNT、MAX、MIN -》功能:用于实现数据分区后的聚合 -》语法:fun_name(col1) over (partition by col2 order by col3) 实现功能 over 按照什么分区,分区内部按照什么排序 -》示例:实现分区内的累加,其他的原理类似 -》区别: 聚合函数:分组 group by :一组返回一条 开窗聚合:分区 partition by:将相同的数据放到一起 –创建文件:vim /export/datas/window.txt coo原创 2021-04-26 10:50:23 · 2215 阅读 · 0 评论 -
hive中处理json数据的函数
Hive中处理json数据的两种方式 第一种:将json数据作为字符串进行处理 使用函数: get_json_object:解析json数据,返回对应的数据 json_tuple:UDTF函数 使用案例: –创建数据:vim /export/datas/hivedata.json {“id”: 1701439105,“ids”: [2154137571,3889177061],“total_number”: 493} {“id”: 1701439106,“ids”: [2154137571,38891770原创 2021-04-26 10:42:10 · 896 阅读 · 0 评论 -
Hive中explode、lateral view以及行列转换的使用
=====================================lateral view================================== 分类:视图 功能:配合UDTF来使用,把某一行数据拆分成多行数据 与UDTF直接使用的区别: 很多的UDTF不能将结果与源表进行关联,使用lateral view 可以将UDTF拆分的单个字段数据与原始表数据关联上 使用方式: tabelA lateral view UDTF(xxx) 视图名 ...原创 2021-04-26 10:39:34 · 458 阅读 · 0 评论 -
Hive中UDF的使用方法
UDF: 1-开发udf程序:继承UDF类,实现一个或者多个evaluate方法 2-打成jar包 3-上传jar包到集群中,并添加到hive的环境变量中,在hive中执行 add jar /export/datas/udf.jar; 4-创建临时函数: create temporary function transDate as 'cn.itcast.bigdata.hive.TransDate'; 5-测试函数: select transDate("18/Aug/2019:12...原创 2021-04-26 10:33:29 · 1110 阅读 · 0 评论