我有以下hql
SELECT count(*) OVER (PARTITION BY identity.hwid, passwordused.domain ORDER BY event.time ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING) pocet,
min(event.time) OVER (PARTITION BY identity.hwid, passwordused.domain ORDER BY event.time ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING) minTime,
max(event.time) OVER (PARTITION BY identity.hwid, passwordused.domain ORDER BY event.time ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING) maxTime
FROM t21_pam6
如何将3个相同的窗口子句定义为一个?
文件(https://cwiki.apache.org/confluence/display/hive/languagemanual+windowingandanalytics )显示此示例
SELECT a, SUM(b) OVER w
FROM T;
WINDOW w AS (PARTITION BY c ORDER BY d ROWS UNBOUNDED PRECEDING)
但我觉得没用。不可能将窗口w定义为。。。不是hql命令。
2条答案
按热度按时间ie3xauqp1#
这种类型的优化是编译器需要做的事情。我不认为有一种方法可以通过编程来确保这一点。
也就是说,最短时间的计算是完全没有必要的。因为
order by
,应该是当前行中的时间。同样,如果你能处理null
值,则表达式可以简化为:请注意
maxtime
计算略有不同,因为它将返回NULL
最后两个匹配条件的值。dl5txlt92#
正如@sergey khudyakov所回应的,文档中有一个bug。此变体工作正常: