[ https://issues.apache.org/jira/browse/CASSANDRA-9457?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14567124#comment-14567124 ]
Sylvain Lebresne commented on CASSANDRA-9457: --------------------------------------------- bq. The intention of these special compose_ methods is that Java UDFs with RETURNS NULL ON NULL INPUT get the primitive types in the signature. Yes, I understand that. What I'm saying is that since those special compose are only ever use when the function uses {{RETURNS NULL ON NULL INPUT}}, then those methods should never be effectively called with null/empty inputs (since the whole function should be bypassed before we reach the call to these methods). So why do these special compose methods test their inputs for null/empty and return some default value? It's useless and confusing. Instead they should assert that the input is not null/empty since it would be a bug. > 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 > Fix For: 2.2.0 rc1 > > > 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)