Spark SQL核心功能概述
发布时间
阅读量:
阅读量
1.开窗函数
1. row_number() over()
- 示例: row_number window function OVER (PARTITION BY category ORDER BY revenue DESC) rank
作用: 该窗口函数为每个分类中的数据按收入降序排列后赋予其所在组内的行号(用于分组topN分析)
常见的聚合函数包括SUM、MAX、MIN以及COUNT等,在数据处理中被广泛应用于统计分析。例如,在SQL查询中可以使用sum(pv) over(partition by cookieid order by createtime) as pv1这一表达式来实现累加计算功能。其作用在于对每个分组按时间顺序排序后,在相邻记录间进行累加运算以获取累积值。
window子句:
- rows spanning from ... to ...(位置不可互换)
- unbounded preceding indicates starting from the first row.
- current row is the present line.
- The first line is governed by unbounded preceding.
- The last line is co
全部评论 (0)
还没有任何评论哟~
