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

Cannot perform slice reads in reverse direction against tables with clustering columns in mixed order

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • 2.2.14
    • Legacy/CQL
    • None
    • Normal

    Description

      CASSANDRA-11196 accidentally broke reading from tables with mixed clustering column order in the opposite direction.

      ReversedPrimaryKeyRestrictions::boundsAsComposites method attempts to reverse the list returned from PrimaryKeyRestrictionSet::boundsAsComposites and fails, as Guava’s Lists::transform method returns a List that doesn’t support set().

      Reproduction:

      CREATE TABLE test.test (
          a int,
          b int,
          c int,
          PRIMARY KEY (a, b, c)
      ) WITH CLUSTERING ORDER BY (b ASC, c DESC);
      
      SELECT * FROM test.test WHERE a = 0 AND (b, c) > (0, 0) ORDER BY b DESC, c ASC;
      
      > ServerError: java.lang.UnsupportedOperationException
      
      java.lang.UnsupportedOperationException: null
      	at java.util.AbstractList.set(AbstractList.java:132) ~[na:1.8.0_181]
      	at java.util.Collections.swap(Collections.java:497) ~[na:1.8.0_181]
      	at java.util.Collections.reverse(Collections.java:378) ~[na:1.8.0_181]
      	at org.apache.cassandra.cql3.restrictions.ReversedPrimaryKeyRestrictions.boundsAsComposites(ReversedPrimaryKeyRestrictions.java:63) ~[main/:na]
      	at org.apache.cassandra.cql3.restrictions.StatementRestrictions.getClusteringColumnsBoundsAsComposites(StatementRestrictions.java:580) ~[main/:na]
      	at org.apache.cassandra.cql3.statements.SelectStatement.makeFilter(SelectStatement.java:418) ~[main/:na]
      	at org.apache.cassandra.cql3.statements.SelectStatement.getSliceCommands(SelectStatement.java:359) ~[main/:na]
      	at org.apache.cassandra.cql3.statements.SelectStatement.getPageableCommand(SelectStatement.java:191) ~[main/:na]
      	at org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:172) ~[main/:na]
      

      Attachments

        Activity

          People

            aleksey Aleksey Yeschenko
            aleksey Aleksey Yeschenko
            Aleksey Yeschenko
            Alex Petrov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: