You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Robert Stupp (JIRA)" <ji...@apache.org> on 2014/12/12 00:33:14 UTC

[jira] [Comment Edited] (CASSANDRA-8374) Better support of null for UDF

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

Robert Stupp edited comment on CASSANDRA-8374 at 12/11/14 11:32 PM:
--------------------------------------------------------------------

Added optional {{ALLOW NULL}} to arguments and return type.
For _java_ source UDFs {{ALLOW NULL}} also means that the Java primitive types (e.g. {{int}} instead of {{j.l.Integer}}) are used making the Java source much nicer:
{code:title=current state}
return val == null ? null : Double.valueOf(Math.sin(val.doubleValue()));
{code}
becomes
{code:title=with ALLOW NULL for arg and return}
return Math.sin(val);
{code}

I'm just thinking of whether to use {{ALLOW NULL}} for each individual argument and the return type or to use {{ALLOW NULLS}} globally.

It's not much effort to additionally allow something like {{DEFAULT a_value}} for a UDF argument. Seems to be a nice option.

(The linked git branch is not ready for review yet)


was (Author: snazy):
Added optional {{ALLOW NULL}} to arguments and return type.
For _java_ source UDFs {{ALLOW NULL}} also means that the Java primitive types (e.g. {{int}} instead of {{j.l.Integer}}) are used making the Java source much nicer:
{code:title=current state}
return val == null ? null : Double.valueOf(Math.sin(val.doubleValue()));
{code}
becomes
{code:title=with ALLOW NULL for arg and return}
return Math.sin(val);
{code}

I'm just thinking of whether to use {{ALLOW NULL}} for each individual argument and the return type or to use {{ALLOW NULLS}} globally.

It's not much effort to alternatively allow something like {{DEFAULT a_value}} for a UDF argument. Seems to be a nice option.

(The linked git branch is not ready for review yet)

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