Cassandra
  1. Cassandra
  2. CASSANDRA-4926

CQL3: IN relation does not work for last part of composite key

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Everything below was done using cqlsh -3, against single node Cassandra 1.1.6.

      I created a test table with the following definition:

      CREATE TABLE testtable (
      a text,
      b text,
      c text,
      data text,
      PRIMARY KEY (a, b, c)
      ) WITH
      comment='' AND
      caching='KEYS_ONLY' AND
      read_repair_chance=0.100000 AND
      gc_grace_seconds=864000 AND
      replicate_on_write='true' AND
      compaction_strategy_class='SizeTieredCompactionStrategy' AND
      compression_parameters:sstable_compression='SnappyCompressor';

      and inserted some data:

      INSERT INTO testtable (a, b, c, data) VALUES ('1', '1', '1', 'data 1');
      INSERT INTO testtable (a, b, c, data) VALUES ('1', '1', '2', 'data 2');
      INSERT INTO testtable (a, b, c, data) VALUES ('1', '1', '3', 'data 3');

      so a full table query produced:

      cqlsh:testkeyspace> select * from testtable;
      a | b | c | data
      ----+-------
      1 | 1 | 1 | data 1
      1 | 1 | 2 | data 2
      1 | 1 | 3 | data 3

      Next I tried the following query with an IN relation on the second part of the key:

      cqlsh:testkeyspace> select * from testtable where a = '1' and b in ('1', '2');
      Bad Request: PRIMARY KEY part b cannot be restricted by IN relation (only the first and last parts can)

      which is apparently not supported, but the error message suggests an IN relation in the last part is supported, so I tried:

      cqlsh:testkeyspace> select * from testtable where a = '1' and b = '1' and c in ('1', '2');
      cqlsh:testkeyspace>

      which did not produce an error, but also returned no results. I was expecting 2 rows. This seems to be a bug?

      Note that I get the expected result if the IN relation contains only 1 value:

      cqlsh:testkeyspace> select * from testtable where a = '1' and b = '1' and c in ('1');
      a | b | c | data
      ----+-------
      1 | 1 | 1 | data 1

        Activity

        Hide
        Aleksey Yeschenko added a comment -

        This query works properly in CQL3 in Cassandra 1.2. During 1.1, however, CQL3 was in beta, and it's not going to be fixed.

        Show
        Aleksey Yeschenko added a comment - This query works properly in CQL3 in Cassandra 1.2. During 1.1, however, CQL3 was in beta, and it's not going to be fixed.

          People

          • Assignee:
            Unassigned
            Reporter:
            Roland Mechler
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development