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

group by select queries query results differ when using select * vs select fields

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Low
    • Resolution: Fixed
    • Fix Version/s: 3.11.3
    • Component/s: None
    • Labels:
      None
    • Severity:
      Low

      Description

      I get two different out with these 2 queries.  The only difference between the 2 queries is that one does ‘select *’ and other does ‘select specific fields’ without any aggregate functions.

      I am using Apache Cassandra 3.10.

      Consistency level set to LOCAL_QUORUM.
      cassandra@cqlsh> select * from wp.position where account_id = 'user_1';

      {{ account_id | security_id | counter | avg_exec_price | pending_quantity | quantity | transaction_id | update_time}}
      ---------------------------------------------------------------------------------+--------------------------------
      {{ user_1 | AMZN | 2 | 1239.2 | 0 | 1011 | null | 2018-01-25 17:18:07.158000+0000}}
      {{ user_1 | AMZN | 1 | 1239.2 | 0 | 1010 | null | 2018-01-25 17:18:07.158000+0000}}

      (2 rows)
      cassandra@cqlsh> select * from wp.position where account_id = 'user_1' group by security_id;

      {{ account_id | security_id | counter | avg_exec_price | pending_quantity | quantity | transaction_id | update_time}}
      ---------------------------------------------------------------------------------+--------------------------------
      {{ user_1 | AMZN | 1 | 1239.2 | 0 | 1010 | null | 2018-01-25 17:18:07.158000+0000}}

      (1 rows)
      cassandra@cqlsh> select account_id,security_id, counter, avg_exec_price,quantity, update_time from wp.position where account_id = 'user_1' group by security_id ;

      {{ account_id | security_id | counter | avg_exec_price | quantity | update_time}}
      ---------------------------------------------------+--------------------------------
      {{ user_1 | AMZN | 2 | 1239.2 | 1011 | 2018-01-25 17:18:07.158000+0000}}

      (1 rows)

      Table Description:
      CREATE TABLE wp.position (
      {{ account_id text,}}
      {{ security_id text,}}
      {{ counter bigint,}}
      {{ avg_exec_price double,}}
      {{ pending_quantity double,}}
      {{ quantity double,}}
      {{ transaction_id uuid,}}
      {{ update_time timestamp,}}
      {{ PRIMARY KEY (account_id, security_id, counter)}}
      ) WITH CLUSTERING ORDER BY (security_id ASC, counter DESC) 

        Attachments

        1. Re group by select queries.txt
          4 kB
          Digant Modha

          Activity

            People

            • Assignee:
              blerer Benjamin Lerer
              Reporter:
              dmodha Digant Modha
              Authors:
              Benjamin Lerer
              Reviewers:
              Andres de la Peña
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: