Skip to content

Aggregate function via FFI calls return_type() instead of return_field() #17400

@paleolimbot

Description

@paleolimbot

Describe the bug

I'm not sure if this is intentional, but this code:

unsafe extern "C" fn return_type_fn_wrapper(
udaf: &FFI_AggregateUDF,
arg_types: RVec<WrappedSchema>,
) -> RResult<WrappedSchema, RString> {
let udaf = udaf.inner();
let arg_types = rresult_return!(rvec_wrapped_to_vec_datatype(&arg_types));
let return_type = udaf
.return_type(&arg_types)
.and_then(|v| FFI_ArrowSchema::try_from(v).map_err(DataFusionError::from))
.map(WrappedSchema);
rresult!(return_type)
}

...triggered a failure in one of my tests because it calls return_type() instead of return_field(). I had been making the assumption that if return_field() was implemented then return_type() shouldn't be called, so I had been returning an error from that function.

I believe that the FFI schemas should be able to carry field metadata...should return_field() be called here?

To Reproduce

Implement an aggregate function that returns an extension type. I believe that when this happens, the metadata on output will be lost or the source return_type() will be called instead of the return_field() implementation.

Expected behavior

I would have expected the field information to propagate to the output.

Additional context

cc @timsaucer ...help!

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions