jayzhan211 commented on code in PR #13564:
URL: https://github.com/apache/datafusion/pull/13564#discussion_r1865744969


##########
datafusion/core/tests/fuzz_cases/aggregation_fuzzer/data_generator.rs:
##########
@@ -87,7 +87,12 @@ impl DatasetGeneratorConfig {
             .iter()
             .filter_map(|d| {
                 if d.column_type.is_numeric()
-                    && !matches!(d.column_type, DataType::Float32 | 
DataType::Float64)
+                    && !matches!(

Review Comment:
   The real issue is that we have decimal(38, 10) which is the fixed precision 
for `sum` and it mismatches with the fuzz test which has random precision
   
   ```rust
       fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
           match &arg_types[0] {
               DataType::Int64 => Ok(DataType::Int64),
               DataType::UInt64 => Ok(DataType::UInt64),
               DataType::Float64 => Ok(DataType::Float64),
               DataType::Decimal128(precision, scale) => {
                   // in the spark, the result type is 
DECIMAL(min(38,precision+10), s)
                   // ref: 
https://github.com/apache/spark/blob/fcf636d9eb8d645c24be3db2d599aba2d7e2955a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Sum.scala#L66
                   let new_precision = DECIMAL128_MAX_PRECISION.min(*precision 
+ 10);
                   Ok(DataType::Decimal128(new_precision, *scale))
               }
               DataType::Decimal256(precision, scale) => {
                   // in the spark, the result type is 
DECIMAL(min(38,precision+10), s)
                   // ref: 
https://github.com/apache/spark/blob/fcf636d9eb8d645c24be3db2d599aba2d7e2955a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Sum.scala#L66
                   let new_precision = DECIMAL256_MAX_PRECISION.min(*precision 
+ 10);
                   Ok(DataType::Decimal256(new_precision, *scale))
               }
               other => {
                   exec_err!("[return_type] SUM not supported for {}", other)
               }
           }
       }
   ```



-- 
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]

Reply via email to