berkaysynnada commented on code in PR #11989:
URL: https://github.com/apache/datafusion/pull/11989#discussion_r1722877902


##########
datafusion/expr/src/udaf.rs:
##########
@@ -552,6 +570,14 @@ pub trait AggregateUDFImpl: Debug + Send + Sync {
     fn is_descending(&self) -> Option<bool> {
         None
     }
+
+    /// Returns default value of the function given the input is all `null`.
+    ///
+    /// Most of the aggregate function return Null if input is Null,
+    /// while `count` returns 0 if input is Null
+    fn default_value(&self, data_type: &DataType) -> Result<ScalarValue> {
+        ScalarValue::try_from(data_type)
+    }
 }

Review Comment:
   If an `AggregateUDFImpl ` overrides `is_nullable()` to return false but does 
not set the `default_value()`, it seems that it would indicate it is not 
nullable, yet its `default_value()` would return `null`. Is there a way to 
prevent this behavior? 🤔 



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