liukun4515 commented on a change in pull request #1408:
URL: https://github.com/apache/arrow-datafusion/pull/1408#discussion_r769205257
##########
File path: datafusion/src/physical_plan/expressions/sum.rs
##########
@@ -54,8 +56,15 @@ pub fn sum_return_type(arg_type: &DataType) ->
Result<DataType> {
DataType::UInt8 | DataType::UInt16 | DataType::UInt32 |
DataType::UInt64 => {
Ok(DataType::UInt64)
}
- DataType::Float32 => Ok(DataType::Float32),
- DataType::Float64 => Ok(DataType::Float64),
+ // In the https://www.postgresql.org/docs/8.2/functions-aggregate.html
doc,
+ // the result type of floating-point is FLOAT64 with the double
precision.
+ DataType::Float64 | DataType::Float32 => Ok(DataType::Float64),
+ // Max precision is 38
+ DataType::Decimal(precision, scale) => {
+ // in the spark, the result type is DECIMAL(min(38,precision+10),
s)
Review comment:
@alamb
The same issue is about precision and scale promotion.
In the PG
```
postgres=# \d t1
Table "public.t1"
Column | Type | Collation | Nullable | Default
--------+--------------+-----------+----------+---------
c1 | numeric(4,2) | | |
postgres=# create table test as select sum(c1) from t1;
SELECT 1
postgres=# \d test;
Table "public.test"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
sum | numeric | | |
```
--
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]