ivan-kiselev opened a new issue, #27960: URL: https://github.com/apache/datafusion/issues/27960
### Describe the bug Grouped `array_agg(DISTINCT x)` panics when `x` has Arrow type `RunEndEncoded(Int32, Dictionary(UInt32, Utf8))`. Reproduced on Apache DataFusion `main` at `070e2570` with Arrow 60.2.0. ### To Reproduce Register an in-memory table `t` with four rows. Use group IDs `[0, 0, 0, 1]` for `g` and the strings `["a", "b", "a", "a"]` for `x`. Encode `x` with `Int32` run ends `[1, 2, 4]` and dictionary-encoded run values `["a", "b", "a"]` using `UInt32` keys. ```sql SELECT g, array_agg(DISTINCT x), count(*) FROM t GROUP BY g; ``` The grouped accumulator panics while constructing the result list: ```text ListArray expected data type RunEndEncoded(non-null Int32, Dictionary(UInt32, Utf8)) got RunEndEncoded(non-null Int32, Utf8) for "item" ``` ### Expected behavior Group `0` should contain `a` and `b`, with a count of `3`. Group `1` should contain only `a`, with a count of `1`. The list element type should match the input type. ### Additional context Plain dictionary strings and run-end-encoded plain strings both work. Casting `x` to `VARCHAR` before aggregation also returns the correct values, but loses the encoding. Arrow's `RowConverter` removes the dictionary layer when decoding rows. `datatype_contains_dictionary` does not inspect the value field of `RunEndEncoded`, so the accumulator skips the cast that would restore the declared type. ### 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]
