james-willis opened a new pull request, #7847:
URL: https://github.com/apache/datafusion-comet/pull/7847

   ## Which issue does this PR close?
   
   Closes #7846
   
   ## Rationale for this change
   
   `MaxMinBy`, `Mode`, `SparkMinMax` and `SparkStructMinMax` return their value 
argument's type but implement only `return_type`, so the default `return_field` 
builds the output field from the type alone and the value field's metadata, 
extension types included, is lost. DataFusion's `first_value` and `last_value` 
keep it; these kernels should report the same field.
   
   ## What changes are included in this PR?
   
   - `return_field` on the four aggregates: the field 
`udaf_default_return_field` built, with the function's name, the type 
`return_type` reports and nullable, plus the value argument's metadata, cloned 
whole.
   - The accumulators are unchanged. They build their output from the value's 
`DataType`, which already embeds nested fields, so for a struct value the 
output array has exactly the declared type.
   
   Comet's Final and PartialMerge stages take their inputs as `UnboundColumn`s 
typed from Spark's declared type, without metadata, so the output of a 
two-stage aggregate does not carry the tag to the JVM yet, for these kernels or 
for DataFusion's own. Carrying it across the exchange is a planner change and 
is out of scope here.
   
   ## How are these changes tested?
   
   New unit tests in each file. `return_field_keeps_value_metadata`, 
`return_field_keeps_input_metadata` (twice) and 
`return_field_keeps_struct_metadata` check the returned field's name, type, 
nullability and metadata, and fail without the change. 
`struct_value_keeps_nested_metadata` in `max_min_by.rs` and the accumulator 
part of `return_field_keeps_struct_metadata` check that the array an 
accumulator produces for a struct value with a tagged child has exactly the 
declared type; they pass before and after and document the contract.
   
   `cargo test -p datafusion-comet-spark-expr`, `cargo clippy -p 
datafusion-comet-spark-expr --all-targets -- -D warnings` and `cargo fmt --all 
-- --check` pass locally.
   
   There is no new Spark SQL test because no Spark type that Comet ships 
carries Arrow extension metadata. The aggregates' values, types and nullability 
are unchanged, which the existing suites cover.
   


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