jayzhan211 commented on PR #14289: URL: https://github.com/apache/datafusion/pull/14289#issuecomment-2614161185
> > Maybe we need yet another trait implementation > > I think it could potentially be modeled as a field on `Signature` https://docs.rs/datafusion/latest/datafusion/logical_expr/struct.Signature.html which would minimize the breakages > > Some prior art: > > It appears that spark uses the term non nullable https://spark.apache.org/docs/3.5.3/sql-ref-functions-udf-scalar.html > > I think postgres uses the term `STRICT` -- from he docs: https://www.postgresql.org/docs/current/sql-createfunction.html > > ``` > CALLED ON NULL INPUT > RETURNS NULL ON NULL INPUT > STRICT > CALLED ON NULL INPUT (the default) indicates that the function will be called normally when some of its arguments are null. It is then the function author's responsibility to check for null values if necessary and respond appropriately. > > RETURNS NULL ON NULL INPUT or STRICT indicates that the function always returns null whenever any of its arguments are null. If this parameter is specified, the function is not executed when there are null arguments; instead a null result is assumed automatically. > ``` I prefer to has `Strict` mode by default -- returns nulls if the arguments contains nulls. We can add field `handle_nulls: bool` to `Signature`, `false` by default, the user can easily change to `true` and handle nulls by themselves. Also, I think we can rewrite such function if `handle_nulls` is `false` in **optimizer**, we can check the argument is null or not easily given it should be a `Scalar`, then we can rewrite it to `Null`. -- 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