datafusion icon indicating copy to clipboard operation
datafusion copied to clipboard

Multiple ORDER BY is not supported for RANGE with UNBOUNDED PRECEDING/FOLLOWING

Open mustafasrepo opened this issue 3 years ago • 0 comments

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

RANGE with offset PRECEDING/FOLLOWING requires exactly one ORDER BY column. However, when we enter UNBOUNDED offset to both sides, It should accept multiple ORDER BY columns. When I run the query below using datafusion,

SELECT
  SUM(c2) OVER(ORDER BY c5, c6 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) as summ
FROM aggregate_test_100

the planner gives the error below.

Error: Plan("With window frame of type RANGE, the order by expression must be of length 1, got 2")

Describe the solution you'd like

Add additional check for whether WindowFrameBound fields Preceding and Following are None before giving error above

Describe alternatives you've considered

N.A

Additional context

relevant code section can be found here

arrow-datafusion/planner.rs at c3bf84e334d6a12c89bacec38e2baa02ca2417ac · apache/arrow-datafusion

mustafasrepo avatar Sep 21 '22 14:09 mustafasrepo