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

   ### Describe the bug
   
   `MIN` and `MAX` fail with an internal error when their argument is a 
`RunEndEncoded` column, both as aggregates (grouped or not) and as window 
functions. The same queries work on plain and `Dictionary`-encoded columns, and 
other aggregates such as `SUM` and `AVG` already accept `RunEndEncoded` input.
   
   ### To Reproduce
   
   In `datafusion-cli`:
   
   ```sql
   CREATE TABLE t AS SELECT arrow_cast(arrow_cast(column1, 'UInt32'),
     'RunEndEncoded("run_ends": non-null Int32, "values": UInt32)') AS v
   FROM (VALUES (1), (1), (3));
   
   SELECT max(v) FROM t;
   ```
   
   fails with:
   
   ```
   Internal error: Min/Max accumulator not implemented for type 
RunEndEncoded("run_ends": non-null Int32, "values": UInt32)
   ```
   
   ### Expected behavior
   
   `SELECT max(v) FROM t` returns `3` as `UInt32`, the same as it does for a 
`UInt32` or `Dictionary(Int32, UInt32)` column.
   
   ### Additional context
   
   `MIN`/`MAX` use a user-defined signature, so their argument type comes only 
from `get_min_max_result_type` in 
`datafusion/functions-aggregate/src/min_max.rs`. It unwraps `Dictionary` to its 
value type, which makes the planner insert a cast, but passes `RunEndEncoded` 
through unchanged, so the accumulator receives a type it has no implementation 
for.
   
   #24564 / #24565 added `RunEndEncoded` handling to `coerced_from`, but 
user-defined signatures don't go through that path, so it doesn't cover 
`MIN`/`MAX`.
   
   ### Willingness to contribute
   
   I plan to contribute a fix for this bug independently


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