trinodb / trino

Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)
https://trino.io
Apache License 2.0
10.46k stars 3.01k forks source link

rank ignores frame #24141

Open findepi opened 1 hour ago

findepi commented 1 hour ago

a window function over empty frame should probably not return anything useful, but this returns (1), (2) as if window was ignored

SELECT rank() OVER (ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND 3 PRECEDING)
FROM (VALUES 1, 2) t(a)
findepi commented 1 hour ago

this is probably incorrect query?

kasiafi commented 1 hour ago

Cannot reproduce:

trino> SELECT rank() OVER (ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND 3 PRECEDING)
    -> FROM (VALUES 1, 2) t(a);
Query 20241115_071604_00005_cp885 failed: line 1:32: Cannot specify window frame for rank function

The above error is a correct behavior according to the spec.