cblp opened a new pull request, #26939: URL: https://github.com/apache/datafusion/pull/26939
## Which issue does this PR close? - Closes #26916. ## Rationale for this change `max` and `min` return a value of the type of their argument, but they drop the field metadata of the argument, including Arrow extension types: `max(uuid_col)` is a plain `FixedSizeBinary(16)`. `first_value` already keeps the metadata. ## What changes are included in this PR? - `Max` and `Min` implement `return_field`. It builds the same field as before and adds the metadata of the argument field, as `first_value` does. - `AggregateStatistics` replaces aggregates that the statistics answer, such as `min` and `max` over a Parquet file, with literals. These literals had no metadata, so the result lost it even with the change above. They now get the metadata of the aggregate field. This is the same kind of problem as #26855. ## What is the testing strategy for this PR? New cases in `metadata.slt`: - `max` and `min` without grouping; - with `GROUP BY`, which uses the groups accumulator; - as window functions; - over a Parquet file, where the statistics answer the query. The case checks with `EXPLAIN` that the plan is a projection of literals. A new case in `cast_extension_type_metadata.slt` for `max` and `min` of a `UUID` column, as in the issue. Its input contains a `NULL`, because over a non-null column the query fails with an internal error on nullability. That is a separate bug, #26469. All new cases fail without the change. ## Are there any user-facing changes? The result of `min` and `max` keeps the field metadata of the argument, including extension types. There are no API changes. -- 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]
