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

SELECT on tuple relations are broken for mixed ASC/DESC clustering order

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • 2.2.6, 3.0.4, 3.4
    • None
    • None
    • Normal

    Description

      As noted on CASSANDRA-6875, the tuple notation is broken when the clustering order mixes ASC and DESC directives because the range of data they describe don't correspond to a single continuous slice internally. To copy the example from CASSANDRA-6875:

      cqlsh:ks> create table foo (a int, b int, c int, PRIMARY KEY (a, b, c)) WITH CLUSTERING ORDER BY (b DESC, c ASC);
      cqlsh:ks> INSERT INTO foo (a, b, c) VALUES (0, 2, 0);
      cqlsh:ks> INSERT INTO foo (a, b, c) VALUES (0, 1, 0);
      cqlsh:ks> INSERT INTO foo (a, b, c) VALUES (0, 1, 1);
      cqlsh:ks> INSERT INTO foo (a, b, c) VALUES (0, 0, 0);
      cqlsh:ks> SELECT * FROM foo WHERE a=0;
      
       a | b | c
      ---+---+---
       0 | 2 | 0
       0 | 1 | 0
       0 | 1 | 1
       0 | 0 | 0
      
      (4 rows)
      
      cqlsh:ks> SELECT * FROM foo WHERE a=0 AND (b, c) > (1, 0);
      
       a | b | c
      ---+---+---
       0 | 2 | 0
      
      (1 rows)
      

      The last query should really return (0, 2, 0) and (0, 1, 1).

      For that specific example we should generate 2 internal slices, but I believe that with more clustering columns we may have more slices.

      Attachments

        Activity

          People

            marcinszymaniuk Marcin Szymaniuk
            slebresne Sylvain Lebresne
            Marcin Szymaniuk
            Benjamin Lerer
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: