alamb commented on code in PR #19593:
URL: https://github.com/apache/datafusion/pull/19593#discussion_r2761117241


##########
datafusion/functions-aggregate/src/sum.rs:
##########
@@ -143,50 +146,64 @@ macro_rules! downcast_sum {
 #[derive(Debug, PartialEq, Eq, Hash)]
 pub struct Sum {
     signature: Signature,
+    // If true then returns null on overflows
+    try_sum_mode: bool,

Review Comment:
    Maybe the field would be more self describing if it were named 
`null_on_overflow` 🤔 



##########
datafusion/functions-aggregate/src/sum.rs:
##########
@@ -336,6 +424,10 @@ impl AggregateUDFImpl for Sum {
     }
 
     fn set_monotonicity(&self, data_type: &DataType) -> SetMonotonicity {
+        // Can overflow into null
+        if self.try_sum_mode {
+            return SetMonotonicity::NotMonotonic;
+        }

Review Comment:
   I think this is at least safe -- if the sum can overflow and go to null I 
don't think that is captured in the monotonicity calculation 🤔 



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