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

ORDER BY should allow skipping equality-restricted clustering columns

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Low
    • Resolution: Fixed
    • Fix Version/s: 4.0, 4.0-alpha1
    • Component/s: Legacy/CQL
    • Labels:
      None

      Description

      Given a table like the following:

      CREATE TABLE foo (a int, b int, c int, d int, PRIMARY KEY (a, b, c));
      

      We should support a query like this:

      SELECT * FROM foo WHERE a = 0 AND b = 0 ORDER BY c ASC;
      

      Currently, this results in the following error:

      [Invalid query] message="Order by currently only support the ordering of columns following their declared order in the PRIMARY KEY"
      

      However, since b is restricted by an equality restriction, we shouldn't require it to be present in the ORDER BY clause.

      As a workaround, you can use this query instead:

      SELECT * FROM foo WHERE a = 0 AND b = 0 ORDER BY b ASC, c ASC;
      

        Attachments

        1. 10271-3.x.txt
          9 kB
          Brett Snyder
        2. cassandra-2.2-10271.txt
          12 kB
          Brett Snyder

          Activity

            People

            • Assignee:
              adelapena Andres de la Peña
              Reporter:
              thobbs Tom Hobbs
              Authors:
              Andres de la Peña
              Reviewers:
              Benjamin Lerer
              Tester:
              Tom Hobbs
            • Votes:
              1 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: