cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sylvain Lebresne (JIRA)" <>
Subject [jira] [Commented] (CASSANDRA-9457) Empty INITCOND treated as null in aggregate
Date Fri, 29 May 2015 12:12:18 GMT


Sylvain Lebresne commented on CASSANDRA-9457:

Some remarks:
* Shouldn't we just assert that the value is neither null nor empty in the {{compose_*}} methods
(the ones for primitive types)? (haven't looked what the code currently does here, but if
the function is called on nulls then we probably shouldn't allow unboxed primitives).
* Not a fan of having {{testEmptyTypes}} in {{UFTtest}} as that extends {{CQLTester}}, so
let's move it to a simple {{UDHelperTest}} class. We can also make it more readable by having
list of list of types for which {{UDHelper.isNullOrEmpty}} returns true and one for which
it returns false.
* It would be nice to at least add a test for aggregates {{INITCOND}} since that's why this
ticket has been created.

A few nits:
* We shouldn't need to override {{isEmptyValueMeaningless}} in {{FrozenType}} so better not
to do it (to avoid having people wonder why it's there).
* Unneeded imports in UDHelper.

As a side note, providing a direct link to the actual branch to review would be a nice touch
in the future.

> Empty INITCOND treated as null in aggregate
> -------------------------------------------
>                 Key: CASSANDRA-9457
>                 URL:
>             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 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

View raw message