jonahgao commented on code in PR #11256:
URL: https://github.com/apache/datafusion/pull/11256#discussion_r1666430879


##########
datafusion/expr/src/expr_schema.rs:
##########
@@ -322,10 +322,16 @@ impl ExprSchemable for Expr {
                 }
             }
             Expr::Cast(Cast { expr, .. }) => expr.nullable(input_schema),
-            Expr::AggregateFunction(AggregateFunction { func_def, .. }) => {
+            Expr::AggregateFunction(AggregateFunction { func_def, args, .. }) 
=> {
                 match func_def {
+                    // TODO: min/max over non-nullable input should be 
recognized as non-nullable
                     AggregateFunctionDefinition::BuiltIn(fun) => 
fun.nullable(),
                     // TODO: UDF should be able to customize nullability
+                    AggregateFunctionDefinition::UDF(udf)
+                        if udf.name() == "count" && args.len() <= 1 =>

Review Comment:
   
   > I don't know of `count(a,b)` function. If it is added in the future, would 
it be necessarily always producing non-null values?
   
   It looks like it's already supported. I think it is also non-nullable.
   ```
   DataFusion CLI v39.0.0
   > create table t(a int, b int) as values(NULL, NULL);
   0 row(s) fetched.
   Elapsed 0.007 seconds.
   
   > select count(distinct a, b) from t;
   +-------------------------+
   | count(DISTINCT t.a,t.b) |
   +-------------------------+
   | 0                       |
   +-------------------------+
   ```
   



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to