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

composite column not sliced when using IN clause on (other) composite columns

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 2.0.11, 2.1.1
    • Legacy/CQL
    • cassandra 2.0.9

    • Low

    Description

      Hi,

      I'm storing data points in cassandra keyed by a number of values and a timestamp. I'd want to use IN clauses to select points and sliced by time. The in clauses work, but I can't get it to work in combination with the slicing: all values are returned / the range in the where clause seems to be ignored.

      A dumbed down abstract version of my layout and some sample data:

      create table tbl (
        a text,
        b text,
        c int,
        d int,
        primary key ((a), b, c)
      );
      
      insert into tbl (a,b,c,d) values ('a1', 'b1', 1, 1);
      insert into tbl (a,b,c,d) values ('a1', 'b1', 2, 2);
      insert into tbl (a,b,c,d) values ('a1', 'b2', 1, 1);
      insert into tbl (a,b,c,d) values ('a1', 'b2', 2, 2);
      insert into tbl (a,b,c,d) values ('a2', 'b1', 1, 1);
      insert into tbl (a,b,c,d) values ('a2', 'b1', 2, 2);
      insert into tbl (a,b,c,d) values ('a3', 'b2', 1, 1);
      insert into tbl (a,b,c,d) values ('a3', 'b2', 2, 2);
      

      So the table contains:

       a  | b  | c | d
      ----+----+---+---
       a1 | b1 | 1 | 1
       a1 | b1 | 2 | 2
       a1 | b2 | 1 | 1
       a1 | b2 | 2 | 2
       a2 | b1 | 1 | 1
       a2 | b1 | 2 | 2
       a3 | b2 | 1 | 1
       a3 | b2 | 2 | 2
      

      When performing select * from tbl where a in ('a1', 'a2') and (b) in (('b1'), ('b2')) and c > 1; I get:

       a  | b  | c | d
      ----+----+---+---
       a1 | b1 | 1 | 1
       a1 | b1 | 2 | 2
       a1 | b2 | 1 | 1
       a1 | b2 | 2 | 2
       a2 | b1 | 1 | 1
       a2 | b1 | 2 | 2
      

      But I expected:

       a  | b  | c | d
      ----+----+---+---
       a1 | b1 | 2 | 2
       a1 | b2 | 2 | 2
       a2 | b1 | 2 | 2
      

      Am I doing something wrong? Or is c > 1 incorrectly ignored?

      select * from tbl where a in ('a1', 'a2') and b='b1' and c > 1; does correctly produce:

      a  | b  | c | d
      ----+----+---+---
       a1 | b1 | 2 | 2
       a2 | b1 | 2 | 2
      

      So I expect this behaviour to relate to the interworking of the IN clause on the clustering column b and the > predicate on column c.

      Cheers,
      Frens Jan

      Attachments

        1. CASSANDRA-7711.txt
          2 kB
          Benjamin Lerer
        2. CASSANDRA-7711-V2.txt
          4 kB
          Benjamin Lerer

        Activity

          People

            blerer Benjamin Lerer
            frensjan Frens Jan Rumph
            Benjamin Lerer
            Tom Hobbs
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: