fornwall opened a new issue, #24514:
URL: https://github.com/apache/datafusion/issues/24514

   ### Describe the bug
   
   Window functions whose leading `ORDER BY` key is `Time32` or `Time64` fail 
during type coercion, even when no frame clause is specified.
   
   An `ORDER BY` window defaults to `RANGE BETWEEN UNBOUNDED PRECEDING AND 
CURRENT ROW`. These free bounds only need to compare order-key values, and time 
values are orderable.
   
   
   ### To Reproduce
   
   Run:
   
   ```bash
   cargo run --quiet -p datafusion-cli -- -q -c \
     "SELECT x, COUNT(*) OVER (ORDER BY x) FROM (VALUES (arrow_cast('01:00:00', 
'Time64(Microsecond)')), (arrow_cast('02:00:00', 'Time64(Microsecond)')), 
(arrow_cast('02:00:00', 'Time64(Microsecond)'))) AS t(x) ORDER BY x;"
   ```
   
   It fails with an internal error:
   
   ```text
   Error: type_coercion
   caused by
   Internal error: Cannot run range queries on datatype: Time64(Microsecond).
   ```
   
   
   ### Expected behavior
   
   The query should succeed and treat equal time values as peers:
   
   ```text
   01:00:00 1
   02:00:00 3
   02:00:00 3
   ```
   
   Free `RANGE` frames whose bounds are only `UNBOUNDED` or `CURRENT ROW` 
should support time order keys. Finite offsets such as `INTERVAL '1' HOUR 
PRECEDING` should remain unsupported because time/interval arithmetic wraps 
around the 24-hour clock, but they should produce a planning error rather than 
an internal error.
   
   
   ### Additional context
   
   The same problem affects `Time32(Second)`, `Time32(Millisecond)`, 
`Time64(Microsecond)`, `Time64(Nanosecond)`, and dictionary-wrapped time 
values. This is analogous to the binary order-key issue fixed in #24357.


-- 
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