grevend opened a new pull request, #26248:
URL: https://github.com/apache/datafusion/pull/26248
## Which issue does this PR close?
- Closes #26247.
## Rationale for this change
`MIN` and `MAX` fail with an internal error on `RunEndEncoded` columns,
while they work on `Dictionary` columns. See #26247 for a reproducer.
## What changes are included in this PR?
`MIN`/`MAX` use a user-defined signature, so `get_min_max_result_type` alone
decides the argument type. It unwraps `Dictionary` to its value type but passed
`RunEndEncoded` through unchanged, so no cast was planned and the accumulator
received a type it has no implementation for. #24565 added `RunEndEncoded`
handling to `coerced_from`, but user-defined signatures don't go through it.
This PR adds a `RunEndEncoded` arm that recurses into the value type. With
the recursion, `RunEndEncoded<_, Dictionary<K, V>>` coerces to `V`, the same
result type `MAX` gives a plain `Dictionary<K, V>` column. Unwrapping one level
would return the correct value, but type it as `Dictionary<K, V>`.
The existing `Dictionary` arm unwraps only one level. I left it unchanged,
because a dictionary whose values are themselves encoded seems rare. I'm happy
to make it recursive in this PR if you'd prefer the two arms to match.
## What is the testing strategy for this PR?
- `test_get_min_max_return_type_coerce_run_end_encoded` in `min_max.rs`
covers `RunEndEncoded<Int32, UInt32>` → `UInt32` and `RunEndEncoded<Int32,
Dictionary<UInt32, Utf8>>` → `Utf8`.
- New cases in `run_end_encoded.slt` go through SQL planning, so they
exercise the UDAF's coercion path rather than calling the accumulator directly:
- ungrouped `MIN`/`MAX`;
- their result types, via `arrow_typeof`;
- grouped `MIN`/`MAX`;
- `MAX` as a window function;
- `MAX` over `RunEndEncoded<Int32, Dictionary<UInt32, Utf8>>`.
Without the fix, the four `RunEndEncoded<Int32, UInt32>` cases fail with
the error above.
## Are there any user-facing changes?
`MIN` and `MAX` now accept `RunEndEncoded` arguments and return the value
type. There are no API changes.
Generated-by: Claude Code (Claude Opus 5.5). I reviewed the change and can
answer for it.
--
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]