Hive 窗口函数 实现原理
hive中窗口函数的实现,主要是借助于一个叫做 Windowing Table Function 的Partitioned Table Function
Partitioned Table Function
PTF函数的经典结构如下图所示,期输入可以是 :表,子查询,或另一个PTF函数输出,其输出也是一张表
PTF invocation example 英 [ˌɪnvə’keɪʃn] 这个能力,(法律的)实施;[计]调用
items 英 ['aɪtəm] 一件商品(或物品);一则或一条新闻
occur vi 发生;存在;出现;想到
Window Function 与 PTF Function
SQL Windowing ,as a PTF
simple examlple:
group sales data by channel and month
within each channel : compute rank ,dense rank , for each month by sales amount
also compute rank over all months across channels
select channel ,month ,sum(amount),
rank()over(order by sum(amount) desc ) as ra,
dens 34