getChan commented on code in PR #27184:
URL: https://github.com/apache/datafusion/pull/27184#discussion_r4502746743
##########
datafusion/functions-nested/src/array_sum.rs:
##########
@@ -76,8 +85,16 @@ impl ScalarUDFImpl for ArraySum {
&self.signature
}
- fn return_type(&self, _arg_types: &[DataType]) -> Result<DataType> {
- Ok(DataType::Float64)
+ fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
+ let [arg_type] = take_function_args(self.name(), arg_types)?;
+ // Same decimal widening as the `sum` aggregate
+ Ok(match sum_element_type(&base_type(arg_type)) {
Review Comment:
Could we reuse `Sum::return_type` here to avoid duplicating the same
return-type rules?
```rust
fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
let [arg_type] = take_function_args(self.name(), arg_types)?;
let element_type = sum_element_type(&base_type(arg_type));
Sum::new().return_type(&[element_type])
}
```
--
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]