[ https://issues.apache.org/jira/browse/CASSANDRA-10840?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15053889#comment-15053889 ]
Robert Stupp commented on CASSANDRA-10840: ------------------------------------------ The issue is not just INITCOND but also to FINALFUNC - fixed both. Both 2.2 and 3.0 are affected - although in slightly different ways. * 2.2 did never reset anything to "null" (omitting INITCOND or FINALFUNC in a CREATE OR REPLACE AGGREGATE). * 3.0 would have reset INITCOND to null - but not for collections (crux with frozen/non-frozen and empty/null collections), which is why you hit this issue - filed another ticket to check how we deal with that in general Added new utests for both 2.2 and 3.0. Branch for 2.2: https://github.com/snazy/cassandra/tree/10840-aggr-initcond-null-2.2 Branch for 3.0: https://github.com/snazy/cassandra/tree/10840-aggr-initcond-null-3.0 CassCI: http://cassci.datastax.com/view/trunk/search/?q=snazy-10840- > Replacing an aggregate with a new version doesn't reset INITCOND > ---------------------------------------------------------------- > > Key: CASSANDRA-10840 > URL: https://issues.apache.org/jira/browse/CASSANDRA-10840 > Project: Cassandra > Issue Type: Bug > Components: CQL > Environment: Observed in Cassandra 2.2.4, though it might be an issue > in 3.0 as well > Reporter: Sandeep Tamhankar > Assignee: Robert Stupp > Fix For: 2.2.x, 3.0.x, 3.x > > > {code} > use simplex; > CREATE FUNCTION state_group_and_sum(state map<int, int>, star_rating > int) > CALLED ON NULL INPUT > RETURNS map<int, int> > LANGUAGE java > AS 'if (state.get(star_rating) == null) > state.put(star_rating, 1); else state.put(star_rating, ((Integer) > state.get(star_rating)) + 1); return state;'; > CREATE FUNCTION percent_stars(state map<int,int>) > RETURNS NULL ON NULL INPUT > RETURNS map<int, int> > LANGUAGE java AS $$ > Integer sum = 0; > for(Object k : state.keySet()) { > sum = sum + (Integer) state.get((Integer) k); > } > java.util.Map<Integer, Integer> results = new java.util.HashMap<Integer, > Integer>(); > for(Object k : state.keySet()) { > results.put((Integer) k, ((Integer) state.get((Integer) k))*100 / sum); > } > return results; > $$; > {code} > {code} > CREATE OR REPLACE AGGREGATE group_and_sum(int) > SFUNC state_group_and_sum > STYPE map<int, int> > FINALFUNC percent_stars > INITCOND {} > {code} > 1. View the aggregates > {{select * from system.schema_aggregates;}} > 2. Now update > {code} > CREATE OR REPLACE AGGREGATE group_and_sum(int) > SFUNC state_group_and_sum > STYPE map<int, int> > FINALFUNC percent_stars > INITCOND NULL > {code} > 3. View the aggregates > {{select * from system.schema_aggregates;}} > Expected result: > * The update should have made initcond null > Actual result: > * The update did not touch INITCOND. -- This message was sent by Atlassian JIRA (v6.3.4#6332)