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

ORDER BY should allow skipping equality-restricted clustering columns

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 4.0-alpha1, 4.0
    • Legacy/CQL
    • 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. cassandra-2.2-10271.txt
          12 kB
          Brett Snyder
        2. 10271-3.x.txt
          9 kB
          Brett Snyder

        Activity

          People

            adelapena Andres de la Peña
            thobbs Tom Hobbs
            Andres de la Peña
            Benjamin Lerer
            Tom Hobbs Tom Hobbs
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: