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 2015/05/23 12:08:17 UTC

[jira] [Commented] (CASSANDRA-9457) Empty INITCOND treated as null in aggregate

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

Robert Stupp commented on CASSANDRA-9457:
-----------------------------------------

It's caused by the {{parameter.remaining() == 0}} check in {{UDFunction}} [here|https://github.com/snazy/cassandra/blob/8473-udf-null-v2/src/java/org/apache/cassandra/cql3/functions/UDFunction.java#L143].

That check is there to handle empty values in the same way as null values.
Question is, whether i can simply remove the {{parameter.remaining() == 0}} check or whether it's better to add some _if type==String || type==Blob_ ?
Still some doubt about "empty" values.
/cc [~iamaleksey]

> Empty INITCOND treated as null in aggregate
> -------------------------------------------
>
>                 Key: CASSANDRA-9457
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-9457
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Core
>            Reporter: Olivier Michallat
>            Assignee: Robert Stupp
>            Priority: Minor
>
> Given the following test data:
> {code}
> cqlsh:test> create table foo(k int, v int, primary key(k,v));
> cqlsh:test> insert into foo(k,v) values(1,1);
> cqlsh:test> insert into foo(k,v) values(1,2);
> cqlsh:test> insert into foo(k,v) values(1,3);
> {code}
> And the following aggregate definition:
> {code}
> cqlsh:test> CREATE FUNCTION cat(s text, v int)
>             RETURNS NULL ON NULL INPUT
>             RETURNS text 
>             LANGUAGE java
>             AS 'return s + v;';
> cqlsh:test> CREATE AGGREGATE cats(int) SFUNC cat STYPE text INITCOND '';
> {code}
> The following should return '123', but it returns null:
> {code}
> cqlsh:test> select cats(v) from foo where k = 1;
>  test.cats(v)
> ---------------
> {code}
> The empty INITCOND is treated as null, and the SFUNC is never called.



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