当前位置:   article > 正文

hive窗口函数数据范围

hive窗口函数数据范围

window的内包括:

(ROWS | RANGE) BETWEEN (UNBOUNDED | [num]) PRECEDING AND ([num] PRECEDING | CURRENT ROW | (UNBOUNDED | [num]) FOLLOWING)
(ROWS | RANGE) BETWEEN CURRENT ROW AND (CURRENT ROW | (UNBOUNDED | [num]) FOLLOWING)
(ROWS | RANGE) BETWEEN [num] FOLLOWING AND (UNBOUNDED | [num]) FOLLOWING

如何指定了order by,但是没有指定窗口,统计的数据是开始到当前行。

SELECT a, SUM(b) OVER (PARTITION BY c ORDER BY d)

FROM T;

When ORDER BY is specified with missing WINDOW clause, the WINDOW specification defaults to RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.

如果order by和 window都没有指定,那就是整个数据集

SELECT a, COUNT(b) OVER (PARTITION BY c, d)

FROM T;

When both ORDER BY and WINDOW clauses are missing, the WINDOW specification defaults to ROW BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/429552
推荐阅读
相关标签
  

闽ICP备14008679号