grevend opened a new issue, #26290:
URL: https://github.com/apache/datafusion/issues/26290
### Describe the bug
`get_min_max_result_type` recurses into `RunEndEncoded` values but unwraps
`Dictionary` only one level. When a dictionary's values are themselves encoded,
MIN/MAX don't reach the plain value type:
| Column type | `max(c)` |
| --- | --- |
| `Dictionary<Int32, RunEndEncoded<Int32, UInt32>>` | `Internal error:
Min/Max accumulator not implemented for type RunEndEncoded(...)` |
| `Dictionary<Int32, Dictionary<Int32, UInt32>>` | correct value, typed
`Dictionary(Int32, UInt32)` instead of `UInt32` |
### To Reproduce
`arrow_cast` can't build these types, so they only come from a
`TableProvider`, e.g. a `MemTable`:
```rust
let values = RunArray::<Int32Type>::try_new(&Int32Array::from(vec![1, 2]),
&UInt32Array::from(vec![1, 3]))?;
let column: ArrayRef =
Arc::new(DictionaryArray::<Int32Type>::try_new(Int32Array::from(vec![0, 0, 1]),
Arc::new(values))?);
// register `column` as `c` in a MemTable `t`, then:
ctx.sql("SELECT max(c) FROM t").await?.collect().await?; // internal error
```
### Expected behavior
Both columns return `max(c) = 3` as `UInt32`, the same as `RunEndEncoded<_,
Dictionary<_, UInt32>>`.
### Additional context
Follow-up to
https://github.com/apache/datafusion/pull/26248#discussion_r4267916127. Making
the `Dictionary` arm recurse like the `RunEndEncoded` arm fixes both cases:
```rust
DataType::Dictionary(_, values) =>
get_min_max_result_type(&[values.deref().clone()]),
```
### 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]