edubraqd opened a new pull request, #24916:
URL: https://github.com/apache/datafusion/pull/24916

   ## Which issue does this PR close?
   
   - Part of #24915. This PR covers `Duration` and `Interval` ORDER BY types; 
`Struct` and `Map` stay rejected because their RANGE peer comparison 
(`partial_cmp_struct` / `partial_cmp_map`) does not match the sort order, and 
are left for a follow-up (fix the comparators, then extend 
`supports_free_range_frame`).
   
   ## Rationale for this change
   
   `OVER (ORDER BY x)` defaults to a free range frame with no offsets, which 
only needs the ORDER BY values to be comparable. `coerce_window_frame` 
nevertheless required an arithmetic target type for the ORDER BY column first, 
so `row_number() OVER (ORDER BY x)` on a `Duration` or `Interval` column failed 
with an internal error asking the user to file a bug.
   
   ## What changes are included in this PR?
   
   Only require the arithmetic target type for frames with a finite offset. A 
free range frame whose ORDER BY expressions are all either arithmetic types or 
`Duration` / `Interval` (also nested in `Dictionary` / `RunEndEncoded`) is 
returned unchanged; every ORDER BY expression is checked, since all of them 
take part in the peer comparison. Frames over supported types are coerced 
exactly as before, so plans do not change. The failure for unsupported types is 
now a planning error, `RANGE window frames are not supported for ORDER BY type 
...`, which fits both free and offset frames.
   
   ## Are these changes tested?
   
   Yes. `window.slt` gains `row_number` / `rank` / `count` over `Duration` and 
`Interval` ORDER BY keys (default and explicit free range frame, single and 
two-column ORDER BY), and checks that `Struct` and `Map` keys, a `Map` after a 
`Duration`, and a finite offset over a `Struct` are still rejected at planning 
time. The existing `Struct` case that pinned the internal-error text now 
expects the planning error.
   
   ## Are there any user-facing changes?
   
   Window functions ordered by `Duration` or `Interval` columns work with the 
default frame. Unsupported ORDER BY types in a RANGE frame report a planning 
error instead of an internal error.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to