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

   ## Which issue does this PR close?
   
   Closes #7844
   
   ## Rationale for this change
   
   `SparkArraysZipFunc` built the struct fields of the zipped element from each 
input's element type, once in `data_type` and again in `arrays_zip_inner`, so 
the metadata of the inputs' item fields was lost. That includes Arrow extension 
types: `arrays_zip` over an array of `geoarrow.wkb`-tagged WKB and an array of 
`arrow.json` documents handed the JVM an `array<struct<...>>` whose children 
were plain binary. The FFI export keeps field metadata, so the loss was in the 
expression.
   
   ## What changes are included in this PR?
   
   - `SparkArraysZipFunc::fields` takes each input's item field from 
`return_field` and uses it whole under its Spark name, nullable as before. 
`data_type` builds the struct from those fields, so the default `return_field` 
reports the children's metadata.
   - `arrays_zip_inner` takes the same fields from the input arrays' list types 
instead of rebuilding them from element types, so the array it returns has the 
type `data_type` declares. The metadata of nested fields is part of the Arrow 
type, and a projection checks its output arrays against the declared type.
   - A `Null`-typed argument stays a nullable `Null` child, as before.
   
   ## How are these changes tested?
   
   New unit test `zipped_struct_keeps_the_item_fields` in `arrays_zip.rs`: two 
list columns whose item fields carry different extension names. It checks that 
the children of `return_field` carry each name under the Spark names and are 
nullable, and that the evaluated array has exactly the declared type. The 
metadata assertions and the type check fail without the change.
   
   `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 types, names and nullability of the 
zipped struct are unchanged, which the existing 
`sql-tests/expressions/array/arrays_zip.sql` cases and 
`CometDecimalPromotionSuite` 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