欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

入门讲解:Hive中的窗口函数系列教程

最编程 2024-07-23 07:21:27
...

基本语法:
Function (arg1,..., argn) OVER ([PARTITION BY <...>] [ORDER BY <....>] [<window_expression>])

Function (arg1,..., argn)可以是下面的函数:

  • Aggregate Functions:聚合函数,如:sum()max()min()avg()
  • Sort Functions:数据排序函数,比如:rank()row_number()
  • Analytics Functions:统计和比较函数,如:lead()lag()first_value()
CREATE TABLE IF NOT EXISTS employee (
name string comment '职工姓名',
dept_num int comment '部门编号',
employee_id int comment '职工ID',
salary int comment '工资',
type string comment '岗位类型',
start_date date comment '入职时间'
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '|'
STORED as TEXTFILE;

加载数据:load data local inpath '/opt/data/employee.txt' into table employee;

推荐阅读