[ 
https://issues.apache.org/jira/browse/CASSANDRA-8374?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14254308#comment-14254308
 ] 

Tyler Hobbs commented on CASSANDRA-8374:
----------------------------------------

{quote}
But I'm not sold on the term RETURNS NULL ON NULL INPUT because such UDA state 
functions must not be used on null input at all (and the state must not 
change). Otherwise it would assume null as the return value, using null as the 
new state, meaning that the state function would never be called again. That 
would mean that such a UDA would always return null if just one row (out of 
many) has a null value.
So I propose just to rename ALLOW NULLS to CALLED ON NULL INPUT and not add 
RETURNS NULL ON NULL INPUT to CQL syntax.
{quote}

If your state function isn't designed to properly handle nulls, then having the 
aggregate return null is not unreasonable.  If there can be nulls, the state 
function should be designed to handle them.  I'm also not sure how ommitting 
{{RETURNS NULL ON NULL INPUT}} from the syntax changes anything?  That behavior 
would still exist, it would just be the default (in Sylvain's current proposal).

> Better support of null for UDF
> ------------------------------
>
>                 Key: CASSANDRA-8374
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-8374
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: Sylvain Lebresne
>            Assignee: Robert Stupp
>             Fix For: 3.0
>
>         Attachments: 8473-1.txt, 8473-2.txt
>
>
> Currently, every function needs to deal with it's argument potentially being 
> {{null}}. There is very many case where that's just annoying, users should be 
> able to define a function like:
> {noformat}
> CREATE FUNCTION addTwo(val int) RETURNS int LANGUAGE JAVA AS 'return val + 2;'
> {noformat}
> without having this crashing as soon as a column it's applied to doesn't a 
> value for some rows (I'll note that this definition apparently cannot be 
> compiled currently, which should be looked into).  
> In fact, I think that by default methods shouldn't have to care about 
> {{null}} values: if the value is {{null}}, we should not call the method at 
> all and return {{null}}. There is still methods that may explicitely want to 
> handle {{null}} (to return a default value for instance), so maybe we can add 
> an {{ALLOW NULLS}} to the creation syntax.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to