james-willis opened a new issue, #7850:
URL: https://github.com/apache/datafusion-comet/issues/7850
### Describe the bug
`CometCollectList` and `CometCollectSet`
(`native/spark-expr/src/agg_funcs/collect.rs`) take `return_type` and
`state_fields` from `datafusion_spark`'s `SparkCollectList` and
`SparkCollectSet`, which build the list item field from the element type alone
(`Field::new_list_field(arg_types[0], true)`), and their accumulators build
every list the same way. `SparkPivotFirst` (`pivot_first.rs`) builds its list
from the value type it was constructed with. In all three the metadata of the
collected value's field is lost from the output field, the state field and the
arrays themselves.
That includes Arrow extension types. `collect_list(g)` over a column tagged
`ARROW:extension:name = geoarrow.wkb` returns `array<binary>` whose item field
has no tag, so the JVM receives an array of plain binary where it expects
geometries. DataFusion's own `array_agg` has the same gap
(apache/datafusion#21982); these are Comet's kernels.
As for #7846, Comet's Final and PartialMerge stages type their inputs from
Spark's declared types without metadata, so the tag reaches the JVM only once
that path carries it too. This issue is about what the kernels report and build
for the fields they are given.
### Steps to reproduce
No Spark type that Comet ships carries Arrow extension metadata, so the
shape is a Rust unit test:
```rust
let tag = HashMap::from([("ARROW:extension:name".to_string(),
"geoarrow.wkb".to_string())]);
let value = Arc::new(Field::new("g", DataType::Binary,
false).with_metadata(tag));
let field = CometCollectList::new().return_field(&[Arc::clone(&value)])?;
let DataType::List(item) = field.data_type() else { unreachable!() };
assert!(item.metadata().is_empty()); // passes today
let pivot = Arc::new(Field::new("p", DataType::Utf8, true));
let field = SparkPivotFirst::try_new(DataType::Binary,
pivot_values)?.return_field(&[pivot, value])?;
let DataType::List(item) = field.data_type() else { unreachable!() };
assert!(item.metadata().is_empty()); // passes today
```
`collect_set` behaves as `collect_list`.
### Expected behavior
The list item field is the collected value's field whole, metadata included,
under the list item name and nullable as Spark declares it. `return_field`,
`state_fields` and the arrays the accumulators produce all carry that field, so
the output batch matches its declared schema.
### Additional context
Same class as #7768, #7769, #7844 and #7846. Found with a geometry UDT
mapped to the `geoarrow.wkb` extension type in a downstream build of Comet.
### Willingness to contribute
I can 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]