liukun4515 commented on issue #1356: URL: https://github.com/apache/arrow-datafusion/issues/1356#issuecomment-977915679
By the way, I think there is a [bug](https://github.com/apache/arrow-datafusion/blob/645a7f484435d7182d88a541ac8cdf8b079b7714/datafusion/src/physical_plan/aggregates.rs#L138). ``` let name = name.into(); let arg = coerce(args, input_schema, &signature(fun))?; if arg.is_empty() { return Err(DataFusionError::Plan(format!( "Invalid or wrong number of arguments passed to aggregate: '{}'", name, ))); } let arg = arg[0].clone(); let arg_types = args .iter() .map(|e| e.data_type(input_schema)) .collect::<Result<Vec<_>>>()?; let return_type = return_type(fun, &arg_types)?; ``` The `args` is the original physical exprs, and the `arg` is the coerced physical exprs. In order to get the result type, we need replace ``` let arg_types = args .iter() .map(|e| e.data_type(input_schema)) .collect::<Result<Vec<_>>>()?; ``` with ``` let arg_types = arg .iter() .map(|e| e.data_type(input_schema)) .collect::<Result<Vec<_>>>()?; ``` In the [functions.rs](https://github.com/apache/arrow-datafusion/blob/645a7f484435d7182d88a541ac8cdf8b079b7714/datafusion/src/physical_plan/functions.rs#L1139), I think the usage is right. -- 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]
