Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-10840

Replacing an aggregate with a new version doesn't reset INITCOND

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Fix Version/s: 2.2.6, 3.0.4, 3.4
    • Component/s: Legacy/CQL
    • Labels:
      None
    • Environment:

      Observed in Cassandra 2.2.4, though it might be an issue in 3.0 as well

    • Severity:
      Normal

      Description

      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;
      $$;
      
      CREATE OR REPLACE AGGREGATE group_and_sum(int)
                          SFUNC state_group_and_sum
                          STYPE map<int, int>
                          FINALFUNC percent_stars
                          INITCOND {}
      

      1. View the aggregates
      select * from system.schema_aggregates;

      2. Now update

      CREATE OR REPLACE AGGREGATE group_and_sum(int)
                          SFUNC state_group_and_sum
                          STYPE map<int, int>
                          FINALFUNC percent_stars
                          INITCOND NULL
      

      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.

        Attachments

          Activity

            People

            • Assignee:
              snazy Robert Stupp
              Reporter:
              stamhankar999 Sandeep Tamhankar
              Authors:
              Robert Stupp
              Reviewers:
              Benjamin Lerer
              Tester:
              Philip Thompson
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: