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

CQL3 Range Query contains unwanted results with composite columns

Log workAgile BoardRank to TopRank to BottomAttach filesAttach ScreenshotBulk Copy AttachmentsBulk Move AttachmentsVotersWatch issueWatchersCreate sub-taskConvert to sub-taskMoveLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Normal

    Description

      Here is a CQL3 range query sample where I get wrong results (tested using cqlsh --cql3) from my perspective:

      CREATE KEYSPACE testing WITH strategy_class = 'SimpleStrategy' AND strategy_options:replication_factor = 1;

      USE testing;

      CREATE TABLE bug_test (a int, b int, c int, d int, e int, f text, PRIMARY KEY (a, b, c, d, e) );

      INSERT INTO bug_test (a, b, c, d, e, f) VALUES (1, 1, 1, 1, 2, '2');
      INSERT INTO bug_test (a, b, c, d, e, f) VALUES (1, 1, 1, 1, 1, '1');
      INSERT INTO bug_test (a, b, c, d, e, f) VALUES (1, 1, 1, 2, 1, '1');
      INSERT INTO bug_test (a, b, c, d, e, f) VALUES (1, 1, 1, 1, 3, '3');
      INSERT INTO bug_test (a, b, c, d, e, f) VALUES (1, 1, 1, 1, 5, '5');

      ----------

      Normal select everything query:

      SELECT * FROM bug_test;

      Results:

      a | b | c | d | e | f
      ------+--
      1 | 1 | 1 | 1 | 1 | 1
      1 | 1 | 1 | 1 | 2 | 2
      1 | 1 | 1 | 1 | 3 | 3
      1 | 1 | 1 | 1 | 5 | 5
      1 | 1 | 1 | 2 | 1 | 1

      Everything fine so far.

      ----------

      Select with greater equal comparison for last column of composite key:

      SELECT a, b, c, d, e, f FROM bug_test WHERE a = 1 AND b = 1 AND c = 1 AND d = 1 AND e >= 2;

      Results:

      a | b | c | d | e | f
      ------+--
      1 | 1 | 1 | 1 | 2 | 2
      1 | 1 | 1 | 1 | 3 | 3
      1 | 1 | 1 | 1 | 5 | 5
      1 | 1 | 1 | 2 | 1 | 1

      Bug:
      Why was the last row returned? It shouldn't be there, right?

      ----------

      Select with greater comparison for last column of composite key:

      SELECT a, b, c, d, e, f FROM bug_test WHERE a = 1 AND b = 1 AND c = 1 AND d = 1 AND e > 2;

      Results:
      a | b | c | d | e | f
      ------+--
      1 | 1 | 1 | 1 | 3 | 3
      1 | 1 | 1 | 1 | 5 | 5
      1 | 1 | 1 | 2 | 1 | 1

      Bug:
      Why was the last row returned? It shouldn't be there, right?

      The same issue is also present with between ranges (e >= 1 AND e <= 2)...

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            slebresne Sylvain Lebresne Assign to me
            grinser Reinhard Buchinger
            Sylvain Lebresne
            Jonathan Ellis
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment