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

LIKE query with partition key restriction gives unexpected results

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Low
    • Resolution: Duplicate
    • Fix Version/s: None
    • Component/s: Feature/SASI
    • Labels:
      None
    • Severity:
      Low

      Description

      When trying to query a table using the LIKE keyword and a partial restriction of the partition key, unexpected results are given.

      Either the query is returning the wrong data, or the query shouldn't be allowed since the partition key is being partially restricted. Please see the demonstration below:

      DROP TABLE IF EXISTS example;
       
      CREATE TABLE example (
          indextype text,
          indexref text,
          phrase text,
          PRIMARY KEY ((indextype, indexref), phrase)
      );
       
      CREATE CUSTOM INDEX example_contains ON example(phrase) USING 'org.apache.cassandra.index.sasi.SASIIndex'
      WITH OPTIONS = { 'mode': 'CONTAINS' };
       
      INSERT INTO example(indextype, indexref, phrase) VALUES('A', 'a1', 'potato');
      INSERT INTO example(indextype, indexref, phrase) VALUES('A', 'a2', 'rubato');
      INSERT INTO example(indextype, indexref, phrase) VALUES('B', 'a3', 'tomato');
       
      SELECT * FROM example
       WHERE indextype='A'
        AND phrase LIKE '%ato%'
        allow filtering;
       

      The expected output is

      | indextype | indexref | phrase |
      | A         | a2       | rubato |
      | A         | a1       | potato |
      

      The actual output is

      | indextype | indexref | phrase |
      | B         | a3       | tomato |
      | A         | a2       | rubato |
      | A         | a1       | potato |
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                kelsey.mckenna Kelsey McKenna
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: