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

CQL3 Predicate logic bug when using composite columns

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • 1.1.6
    • None
    • Normal

    Description

      Looks like a predicate logic bug that only happens when you have > 2 primary keys and use COMPACT STORAGE (meaning its using composite columns under the hood)

      First I'll show it works with just 2

      cqlsh:dev> CREATE TABLE testrev (
             ...          key text,
             ...          rdate timestamp,
             ...          num double,
             ...          PRIMARY KEY(key,rdate)
             ...          ) WITH COMPACT STORAGE
             ...            AND CLUSTERING ORDER BY(rdate DESC);
      
      cqlsh:dev> INSERT INTO testrev(key,rdate,num) VALUES ('foo','2012-01-01',10.5);
      cqlsh:dev> select * from testrev where key='foo' and rdate > '2012-01-01';
      cqlsh:dev> select * from testrev where key='foo' and rdate >= '2012-01-01';
       key | rdate                    | num
      -----+--------------------------+------
       foo | 2012-01-01 00:00:00-0500 | 10.5
      

      Now we create with 3 parts to the PRIMARY KEY

      cqlsh:dev> drop TABLE testrev ;
      cqlsh:dev> CREATE TABLE testrev (
             ...          key text,
             ...          rdate timestamp,
             ...          rdate2 timestamp,
             ...          num double,
             ...          PRIMARY KEY(key,rdate,rdate2)
             ...          ) WITH COMPACT STORAGE
             ...          AND CLUSTERING ORDER BY(rdate DESC);
      
      cqlsh:dev> INSERT INTO testrev(key,rdate,rdate2,num) VALUES ('foo','2012-01-01','2012-01-01',10.5);
      cqlsh:dev> select * from testrev where key='foo' and rdate > '2012-01-01';
       key | rdate                    | rdate2                   | num
      -----+--------------------------+--------------------------+------
       foo | 2012-01-01 00:00:00-0500 | 2012-01-01 00:00:00-0500 | 10.5
      
      cqlsh:dev> select * from testrev where key='foo' and rdate >= '2012-01-01';
      

      The last query should return the row...

      Attachments

        1. 4759.txt
          4 kB
          Sylvain Lebresne

        Activity

          People

            slebresne Sylvain Lebresne
            tjake T Jake Luciani
            Sylvain Lebresne
            T Jake Luciani
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: