edubraqd opened a new issue, #24915: URL: https://github.com/apache/datafusion/issues/24915
### Describe the bug `OVER (ORDER BY x)` defaults to `RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW`, a "free range" frame with no offsets. Such a frame only needs the ORDER BY values to be comparable, but `coerce_window_frame` (`datafusion/optimizer/src/analyzer/type_coercion.rs`) calls `extract_window_frame_target_type` before checking `free_range()`, and that helper returns an *internal* error for every type without arithmetic. So any window function ordered by a Duration, Interval, Struct or Map column fails, even `row_number()` or `count(*)`, and the message tells the user to file a bug. ### To Reproduce ```sql SELECT x, row_number() OVER (ORDER BY x) FROM (VALUES (arrow_cast(2, 'Duration(Second)')), (arrow_cast(1, 'Duration(Second)'))) t(x); ``` ```text Internal error: Cannot run range queries on datatype: Duration(s). This issue was likely caused by a bug in DataFusion's code. Please help us to resolve this by filing a bug report in our issue tracker: https://github.com/apache/datafusion/issues ``` Same for `interval '1 month'`, `struct(1)` and `map(['a'], [1])` values; `window.slt` even pins the internal-error text for the struct case. ### Expected behavior The query runs (the values sort fine), like it does for a Time column since the free-range handling for those types was added. A frame with a finite offset (`RANGE BETWEEN 1 PRECEDING ...`) over such a type should keep failing, but as a planning error. ### Additional context Found while running a cast matrix of extreme values against a debug build of `datafusion-cli`. -- 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]
