cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ble...@apache.org
Subject cassandra git commit: Fix slice queries on ordered COMPACT tables
Date Thu, 28 Apr 2016 09:02:54 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.2 88f22b969 -> c8d955533


Fix slice queries on ordered COMPACT tables

patch by Alex Petrov; reviewed by Benjamin Lerer for CASSANDRA-10988


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/c8d95553
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/c8d95553
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/c8d95553

Branch: refs/heads/cassandra-2.2
Commit: c8d955533b6968368907e5b090a309ac57bf419f
Parents: 88f22b9
Author: Alex Petrov <oleksandr.petrov@gmail.com>
Authored: Thu Apr 28 11:00:35 2016 +0200
Committer: Benjamin Lerer <b.lerer@gmail.com>
Committed: Thu Apr 28 11:01:58 2016 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |    1 +
 .../cql3/statements/SelectStatement.java        |   19 +-
 .../SelectMultiColumnRelationTest.java          | 1678 +++++++++---------
 .../cql3/validation/operations/SelectTest.java  |   73 +
 4 files changed, 938 insertions(+), 833 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c8d95553/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 91179b3..d5cccfa 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -7,6 +7,7 @@
  * cqlsh: COPY FROM should use regular inserts for single statement batches and
    report errors correctly if workers processes crash on initialization (CASSANDRA-11474)
  * Always close cluster with connection in CqlRecordWriter (CASSANDRA-11553)
+ * Fix slice queries on ordered COMPACT tables (CASSANDRA-10988)
 Merged from 2.1:
  * cqlsh COPY FROM fails for null values with non-prepared statements (CASSANDRA-11631)
  * Make cython optional in pylib/setup.py (CASSANDRA-11630)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c8d95553/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
index 7bba330..20fe982 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@ -611,12 +611,29 @@ public class SelectStatement implements CQLStatement
 
     private CellName makeExclusiveSliceBound(Bound bound, CellNameType type, QueryOptions options) throws InvalidRequestException
     {
-        if (restrictions.areRequestedBoundsInclusive(bound))
+        // clusteringColumnBounds may reverse bound if clustering order is reversed
+        // but areRequestedBoundsInclusive checks for Restriction::isInclusive and never
+        // reverses the order. In order to avoid inconsistencies and check inclusive
+        // bounds correctly, we need to check for column order and reverse it. See CASSANDRA-10988
+        if (restrictions.areRequestedBoundsInclusive(reverseBoundIfNeeded(bound)))
             return null;
 
        return type.makeCellName(restrictions.getClusteringColumnsBounds(bound, options).get(0));
     }
 
+    /**
+     * Reverses the specified bound if the non-compound clustering column is a reversed one.
+     * @param bound bound to reverse
+     * @return the bound reversed if the column type was a reversed one or the original bound
+     */
+    private Bound reverseBoundIfNeeded(Bound bound)
+    {
+        assert !cfm.comparator.isCompound();
+
+        List<ColumnDefinition> columnDefs = cfm.clusteringColumns();
+        return columnDefs.get(columnDefs.size() - 1).isReversedType() ? bound.reverse() : bound;
+    }
+
     private Iterator<Cell> applySliceRestriction(final Iterator<Cell> cells, final QueryOptions options) throws InvalidRequestException
     {
         final CellNameType type = cfm.comparator;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c8d95553/test/unit/org/apache/cassandra/cql3/validation/operations/SelectMultiColumnRelationTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectMultiColumnRelationTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectMultiColumnRelationTest.java
index 3b367f3..a1542ce 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectMultiColumnRelationTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectMultiColumnRelationTest.java
@@ -996,854 +996,868 @@ public class SelectMultiColumnRelationTest extends CQLTester
     @Test
     public void testMixedOrderColumns1() throws Throwable
     {
-        createTable("CREATE TABLE %s (a int, b int, c int, d int, e int, PRIMARY KEY (a, b, c, d, e)) " +
-                "WITH CLUSTERING ORDER BY (b DESC, c ASC, d DESC, e ASC)");
-
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, 0, -1, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, 0, -1, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, 0, 1, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 0, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 1, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 1, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 1, -1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 1, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, -1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, -1, -1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, -1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, -1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, -1, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 0, 0, 0, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, -1, 0, -1, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, -1, 0, 0, 0);
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d,e)<=(?,?,?,?) " +
-                                "AND (b)>(?)", 0, 2, 0, 1, 1, -1),
-
-                row( 0, 2, 0, 1, 1),
-                row( 0, 2, 0, -1, 0),
-                row( 0, 2, 0, -1, 1),
-                row( 0, 1, -1, 1, 0),
-                row( 0, 1, -1, 1, 1),
-                row( 0, 1, -1, 0, 0),
-                row( 0, 1, 0, 1, -1),
-                row( 0, 1, 0, 1, 1),
-                row( 0, 1, 0, 0, -1),
-                row( 0, 1, 0, 0, 0),
-                row( 0, 1, 0, 0, 1),
-                row( 0, 1, 0, -1, -1),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0),
-                row( 0, 1, 1, 0, 1),
-                row( 0, 1, 1, -1, 0),
-                row( 0, 0, 0, 0, 0)
-        );
-
-
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d,e)<=(?,?,?,?) " +
-                                "AND (b)>=(?)", 0, 2, 0, 1, 1, -1),
-
-                row( 0, 2, 0, 1, 1),
-                row( 0, 2, 0, -1, 0),
-                row( 0, 2, 0, -1, 1),
-                row( 0, 1, -1, 1, 0),
-                row( 0, 1, -1, 1, 1),
-                row( 0, 1, -1, 0, 0),
-                row( 0, 1, 0, 1, -1),
-                row( 0, 1, 0, 1, 1),
-                row( 0, 1, 0, 0, -1),
-                row( 0, 1, 0, 0, 0),
-                row( 0, 1, 0, 0, 1),
-                row( 0, 1, 0, -1, -1),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0),
-                row( 0, 1, 1, 0, 1),
-                row( 0, 1, 1, -1, 0),
-                row( 0, 0, 0, 0, 0),
-                row( 0, -1, 0, 0, 0),
-                row( 0, -1, 0, -1, 0)
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d)>=(?,?,?)"+
-                                "AND (b,c,d,e)<(?,?,?,?) ", 0, 1, 1,0,1,  1, 0,1),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0)
-
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d,e)>(?,?,?,?)"+
-                                "AND (b,c,d)<=(?,?,?) ", 0, -1, 0,-1,-1,  2, 0,-1),
-
-                row( 0, 2, 0, -1, 0),
-                row( 0, 2, 0, -1, 1),
-                row( 0, 1, -1, 1, 0),
-                row( 0, 1, -1, 1, 1),
-                row( 0, 1, -1, 0, 0),
-                row( 0, 1, 0, 1, -1),
-                row( 0, 1, 0, 1, 1),
-                row( 0, 1, 0, 0, -1),
-                row( 0, 1, 0, 0, 0),
-                row( 0, 1, 0, 0, 1),
-                row( 0, 1, 0, -1, -1),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0),
-                row( 0, 1, 1, 0, 1),
-                row( 0, 1, 1, -1, 0),
-                row( 0, 0, 0, 0, 0),
-                row( 0, -1, 0, 0, 0),
-                row( 0, -1, 0, -1, 0)
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d,e) < (?,?,?,?) " +
-                                "AND (b,c,d,e)>(?,?,?,?)", 0, 1, 0, 0, 0, 1, 0,-1,-1),
-                row(0, 1, 0, 0, -1)
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d,e) <= (?,?,?,?) " +
-                                "AND (b,c,d,e)>(?,?,?,?)", 0, 1, 0, 0, 0, 1, 0,-1,-1),
-                row(0, 1, 0, 0, -1),
-                row(0, 1, 0, 0, 0)
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b)<(?) " +
-                                "AND (b,c,d,e)>(?,?,?,?)", 0, 2, -1, 0,-1,-1),
-
-                row( 0, 1, -1, 1, 0),
-                row( 0, 1, -1, 1, 1),
-                row( 0, 1, -1, 0, 0),
-                row( 0, 1, 0, 1, -1),
-                row( 0, 1, 0, 1, 1),
-                row( 0, 1, 0, 0, -1),
-                row( 0, 1, 0, 0, 0),
-                row( 0, 1, 0, 0, 1),
-                row( 0, 1, 0, -1, -1),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0),
-                row( 0, 1, 1, 0, 1),
-                row( 0, 1, 1, -1, 0),
-                row( 0, 0, 0, 0, 0),
-                row( 0, -1, 0, 0, 0),
-                row( 0, -1, 0, -1, 0)
-
-        );
-
-
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b)<(?) " +
-                                "AND (b)>(?)", 0, 2, -1),
-
-                row( 0, 1, -1, 1, 0),
-                row( 0, 1, -1, 1, 1),
-                row( 0, 1, -1, 0, 0),
-                row( 0, 1, 0, 1, -1),
-                row( 0, 1, 0, 1, 1),
-                row( 0, 1, 0, 0, -1),
-                row( 0, 1, 0, 0, 0),
-                row( 0, 1, 0, 0, 1),
-                row( 0, 1, 0, -1, -1),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0),
-                row( 0, 1, 1, 0, 1),
-                row( 0, 1, 1, -1, 0),
-                row( 0, 0, 0, 0, 0)
-
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b)<(?) " +
-                                "AND (b)>=(?)", 0, 2, -1),
-
-                row( 0, 1, -1, 1, 0),
-                row( 0, 1, -1, 1, 1),
-                row( 0, 1, -1, 0, 0),
-                row( 0, 1, 0, 1, -1),
-                row( 0, 1, 0, 1, 1),
-                row( 0, 1, 0, 0, -1),
-                row( 0, 1, 0, 0, 0),
-                row( 0, 1, 0, 0, 1),
-                row( 0, 1, 0, -1, -1),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0),
-                row( 0, 1, 1, 0, 1),
-                row( 0, 1, 1, -1, 0),
-                row( 0, 0, 0, 0, 0),
-                row( 0, -1, 0, 0, 0),
-                row( 0, -1, 0, -1, 0)
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d,e)<=(?,?,?,?) " +
-                                "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0, 1, 1, -1, 0,-1,-1),
-
-                row( 0, 2, 0, 1, 1),
-                row( 0, 2, 0, -1, 0),
-                row( 0, 2, 0, -1, 1),
-                row( 0, 1, -1, 1, 0),
-                row( 0, 1, -1, 1, 1),
-                row( 0, 1, -1, 0, 0),
-                row( 0, 1, 0, 1, -1),
-                row( 0, 1, 0, 1, 1),
-                row( 0, 1, 0, 0, -1),
-                row( 0, 1, 0, 0, 0),
-                row( 0, 1, 0, 0, 1),
-                row( 0, 1, 0, -1, -1),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0),
-                row( 0, 1, 1, 0, 1),
-                row( 0, 1, 1, -1, 0),
-                row( 0, 0, 0, 0, 0),
-                row( 0, -1, 0, 0, 0),
-                row( 0, -1, 0, -1, 0)
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c)<=(?,?) " +
-                                "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0, -1, 0,-1,-1),
-
-                row( 0, 2, 0, 1, 1),
-                row( 0, 2, 0, -1, 0),
-                row( 0, 2, 0, -1, 1),
-                row( 0, 1, -1, 1, 0),
-                row( 0, 1, -1, 1, 1),
-                row( 0, 1, -1, 0, 0),
-                row( 0, 1, 0, 1, -1),
-                row( 0, 1, 0, 1, 1),
-                row( 0, 1, 0, 0, -1),
-                row( 0, 1, 0, 0, 0),
-                row( 0, 1, 0, 0, 1),
-                row( 0, 1, 0, -1, -1),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0),
-                row( 0, 1, 1, 0, 1),
-                row( 0, 1, 1, -1, 0),
-                row( 0, 0, 0, 0, 0),
-                row( 0, -1, 0, 0, 0),
-                row( 0, -1, 0, -1, 0)
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d)<=(?,?,?) " +
-                                "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0,-1, -1, 0,-1,-1),
-
-                row( 0, 2, 0, -1, 0),
-                row( 0, 2, 0, -1, 1),
-                row( 0, 1, -1, 1, 0),
-                row( 0, 1, -1, 1, 1),
-                row( 0, 1, -1, 0, 0),
-                row( 0, 1, 0, 1, -1),
-                row( 0, 1, 0, 1, 1),
-                row( 0, 1, 0, 0, -1),
-                row( 0, 1, 0, 0, 0),
-                row( 0, 1, 0, 0, 1),
-                row( 0, 1, 0, -1, -1),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0),
-                row( 0, 1, 1, 0, 1),
-                row( 0, 1, 1, -1, 0),
-                row( 0, 0, 0, 0, 0),
-                row( 0, -1, 0, 0, 0),
-                row( 0, -1, 0, -1, 0)
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d,e)>(?,?,?,?)"+
-                                "AND (b,c,d)<=(?,?,?) ", 0, -1, 0,-1,-1,  2, 0,-1),
-
-                row( 0, 2, 0, -1, 0),
-                row( 0, 2, 0, -1, 1),
-                row( 0, 1, -1, 1, 0),
-                row( 0, 1, -1, 1, 1),
-                row( 0, 1, -1, 0, 0),
-                row( 0, 1, 0, 1, -1),
-                row( 0, 1, 0, 1, 1),
-                row( 0, 1, 0, 0, -1),
-                row( 0, 1, 0, 0, 0),
-                row( 0, 1, 0, 0, 1),
-                row( 0, 1, 0, -1, -1),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0),
-                row( 0, 1, 1, 0, 1),
-                row( 0, 1, 1, -1, 0),
-                row( 0, 0, 0, 0, 0),
-                row( 0, -1, 0, 0, 0),
-                row( 0, -1, 0, -1, 0)
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d)>=(?,?,?)"+
-                                "AND (b,c,d,e)<(?,?,?,?) ", 0, 1, 1,0,1,  1, 0,1),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0)
-        );
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d,e)<(?,?,?,?) "+
-                                "AND (b,c,d)>=(?,?,?)", 0, 1, 1,0,1,1,  1, 0),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0)
-
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c)<(?,?) " +
-                                "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0, -1, 0,-1,-1),
-                row( 0, 1, -1, 1, 0),
-                row( 0, 1, -1, 1, 1),
-                row( 0, 1, -1, 0, 0),
-                row( 0, 1, 0, 1, -1),
-                row( 0, 1, 0, 1, 1),
-                row( 0, 1, 0, 0, -1),
-                row( 0, 1, 0, 0, 0),
-                row( 0, 1, 0, 0, 1),
-                row( 0, 1, 0, -1, -1),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0),
-                row( 0, 1, 1, 0, 1),
-                row( 0, 1, 1, -1, 0),
-                row( 0, 0, 0, 0, 0),
-                row( 0, -1, 0, 0, 0),
-                row( 0, -1, 0, -1, 0)
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c)<(?,?) " +
-                                "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0, -1, 0,-1,-1),
-                row( 0, 1, -1, 1, 0),
-                row( 0, 1, -1, 1, 1),
-                row( 0, 1, -1, 0, 0),
-                row( 0, 1, 0, 1, -1),
-                row( 0, 1, 0, 1, 1),
-                row( 0, 1, 0, 0, -1),
-                row( 0, 1, 0, 0, 0),
-                row( 0, 1, 0, 0, 1),
-                row( 0, 1, 0, -1, -1),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0),
-                row( 0, 1, 1, 0, 1),
-                row( 0, 1, 1, -1, 0),
-                row( 0, 0, 0, 0, 0),
-                row( 0, -1, 0, 0, 0),
-                row( 0, -1, 0, -1, 0)
-        );
-
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) <= (?,?,?,?)", 0, 1, 0, 0, 0),
-                row(0, 1, -1, 1, 0),
-                row(0, 1, -1, 1, 1),
-                row(0, 1, -1, 0, 0),
-                row(0, 1, 0, 0, -1),
-                row(0, 1, 0, 0, 0),
-                row(0, 1, 0, -1, -1),
-                row(0, 0, 0, 0, 0),
-                row(0, -1, 0, 0, 0),
-                row(0, -1, 0, -1, 0)
-        );
-
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) > (?,?,?,?)", 0, 1, 0, 0, 0),
-                row(0, 2, 0, 1, 1),
-                row(0, 2, 0, -1, 0),
-                row(0, 2, 0, -1, 1),
-                row(0, 1, 0,  1, -1),
-                row(0, 1, 0,  1, 1),
-                row(0, 1, 0,  0, 1),
-                row(0, 1, 1,  0, -1),
-                row(0, 1, 1,  0, 0),
-                row(0, 1, 1,  0, 1),
-                row(0, 1, 1, -1, 0)
-        );
-
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) >= (?,?,?,?)", 0, 1, 0, 0, 0),
-                row( 0, 2, 0, 1, 1),
-                row(0, 2, 0, -1, 0),
-                row(0, 2, 0, -1, 1),
-                row(0, 1, 0,  1, -1),
-                row(0, 1, 0,  1, 1),
-                row(0, 1, 0,  0, 0),
-                row(0, 1, 0,  0, 1),
-                row(0, 1, 1,  0, -1),
-                row(0, 1, 1,  0, 0),
-                row(0, 1, 1,  0, 1),
-                row(0, 1, 1, -1, 0)
-        );
-
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d) >= (?,?,?)", 0, 1, 0, 0),
-                row( 0, 2, 0, 1, 1),
-                row(0, 2, 0, -1, 0),
-                row(0, 2, 0, -1, 1),
-                row(0, 1, 0,  1, -1),
-                row(0, 1, 0,  1, 1),
-                row(0, 1, 0,  0, -1),
-                row(0, 1, 0,  0, 0),
-                row(0, 1, 0,  0, 1),
-                row(0, 1, 1,  0, -1),
-                row(0, 1, 1,  0, 0),
-                row(0, 1, 1,  0, 1),
-                row(0, 1, 1, -1, 0)
-        );
-
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d) > (?,?,?)", 0, 1, 0, 0),
-                row(0, 2, 0, 1, 1),
-                row(0, 2, 0, -1, 0),
-                row(0, 2, 0, -1, 1),
-                row(0, 1, 0,  1, -1),
-                row(0, 1, 0,  1, 1),
-                row(0, 1, 1,  0, -1),
-                row(0, 1, 1,  0, 0),
-                row(0, 1, 1,  0, 1),
-                row(0, 1, 1, -1, 0)
-        );
-
+        for (String compactOption : new String[]{"", " COMPACT STORAGE AND "})
+        {
+            createTable("CREATE TABLE %s (a int, b int, c int, d int, e int, PRIMARY KEY (a, b, c, d, e)) WITH " +
+                        compactOption +
+                        " CLUSTERING ORDER BY (b DESC, c ASC, d DESC, e ASC)");
+
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, 0, -1, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, 0, -1, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, 0, 1, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 0, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 1, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 1, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 1, -1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 1, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, -1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, -1, -1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, -1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, -1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, -1, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 0, 0, 0, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, -1, 0, -1, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, -1, 0, 0, 0);
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d,e)<=(?,?,?,?) " +
+            "AND (b)>(?)", 0, 2, 0, 1, 1, -1),
+
+                       row(0, 2, 0, 1, 1),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 0, 0, 0, 0)
+            );
+
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d,e)<=(?,?,?,?) " +
+            "AND (b)>=(?)", 0, 2, 0, 1, 1, -1),
+
+                       row(0, 2, 0, 1, 1),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 0, 0, 0, 0),
+                       row(0, -1, 0, 0, 0),
+                       row(0, -1, 0, -1, 0)
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d)>=(?,?,?)" +
+            "AND (b,c,d,e)<(?,?,?,?) ", 0, 1, 1, 0, 1, 1, 0, 1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0)
+
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d,e)>(?,?,?,?)" +
+            "AND (b,c,d)<=(?,?,?) ", 0, -1, 0, -1, -1, 2, 0, -1),
+
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 0, 0, 0, 0),
+                       row(0, -1, 0, 0, 0),
+                       row(0, -1, 0, -1, 0)
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d,e) < (?,?,?,?) " +
+            "AND (b,c,d,e)>(?,?,?,?)", 0, 1, 0, 0, 0, 1, 0, -1, -1),
+                       row(0, 1, 0, 0, -1)
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d,e) <= (?,?,?,?) " +
+            "AND (b,c,d,e)>(?,?,?,?)", 0, 1, 0, 0, 0, 1, 0, -1, -1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0)
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b)<(?) " +
+            "AND (b,c,d,e)>(?,?,?,?)", 0, 2, -1, 0, -1, -1),
+
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 0, 0, 0, 0),
+                       row(0, -1, 0, 0, 0),
+                       row(0, -1, 0, -1, 0)
+
+            );
+
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b)<(?) " +
+            "AND (b)>(?)", 0, 2, -1),
+
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 0, 0, 0, 0)
+
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b)<(?) " +
+            "AND (b)>=(?)", 0, 2, -1),
+
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 0, 0, 0, 0),
+                       row(0, -1, 0, 0, 0),
+                       row(0, -1, 0, -1, 0)
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d,e)<=(?,?,?,?) " +
+            "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0, 1, 1, -1, 0, -1, -1),
+
+                       row(0, 2, 0, 1, 1),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 0, 0, 0, 0),
+                       row(0, -1, 0, 0, 0),
+                       row(0, -1, 0, -1, 0)
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c)<=(?,?) " +
+            "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0, -1, 0, -1, -1),
+
+                       row(0, 2, 0, 1, 1),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 0, 0, 0, 0),
+                       row(0, -1, 0, 0, 0),
+                       row(0, -1, 0, -1, 0)
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d)<=(?,?,?) " +
+            "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0, -1, -1, 0, -1, -1),
+
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 0, 0, 0, 0),
+                       row(0, -1, 0, 0, 0),
+                       row(0, -1, 0, -1, 0)
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d,e)>(?,?,?,?)" +
+            "AND (b,c,d)<=(?,?,?) ", 0, -1, 0, -1, -1, 2, 0, -1),
+
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 0, 0, 0, 0),
+                       row(0, -1, 0, 0, 0),
+                       row(0, -1, 0, -1, 0)
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d)>=(?,?,?)" +
+            "AND (b,c,d,e)<(?,?,?,?) ", 0, 1, 1, 0, 1, 1, 0, 1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0)
+            );
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d,e)<(?,?,?,?) " +
+            "AND (b,c,d)>=(?,?,?)", 0, 1, 1, 0, 1, 1, 1, 0),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0)
+
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c)<(?,?) " +
+            "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0, -1, 0, -1, -1),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 0, 0, 0, 0),
+                       row(0, -1, 0, 0, 0),
+                       row(0, -1, 0, -1, 0)
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c)<(?,?) " +
+            "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0, -1, 0, -1, -1),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 0, 0, 0, 0),
+                       row(0, -1, 0, 0, 0),
+                       row(0, -1, 0, -1, 0)
+            );
+
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) <= (?,?,?,?)", 0, 1, 0, 0, 0),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 0, 0, 0, 0),
+                       row(0, -1, 0, 0, 0),
+                       row(0, -1, 0, -1, 0)
+            );
+
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) > (?,?,?,?)", 0, 1, 0, 0, 0),
+                       row(0, 2, 0, 1, 1),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0)
+            );
+
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) >= (?,?,?,?)", 0, 1, 0, 0, 0),
+                       row(0, 2, 0, 1, 1),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0)
+            );
+
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d) >= (?,?,?)", 0, 1, 0, 0),
+                       row(0, 2, 0, 1, 1),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0)
+            );
+
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d) > (?,?,?)", 0, 1, 0, 0),
+                       row(0, 2, 0, 1, 1),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0)
+            );
+        }
     }
 
     @Test
     public void testMixedOrderColumns2() throws Throwable
     {
-        createTable("CREATE TABLE %s (a int, b int, c int, d int, e int, PRIMARY KEY (a, b, c, d, e)) " +
-                "WITH CLUSTERING ORDER BY (b DESC, c ASC, d ASC, e ASC)");
-
-        // b and d are reversed in the clustering order
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, 0, -1, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, 0, -1, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 0, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 1, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 1, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 1, -1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 1, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, -1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, -1, -1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, -1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, -1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, -1, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 0, 0, 0, 0);
+        for (String compactOption : new String[]{"", " COMPACT STORAGE AND "})
+        {
+            createTable("CREATE TABLE %s (a int, b int, c int, d int, e int, PRIMARY KEY (a, b, c, d, e)) WITH " +
+                        compactOption +
+                        "CLUSTERING ORDER BY (b DESC, c ASC, d ASC, e ASC)");
 
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) <= (?,?,?,?)", 0, 1, 0, 0, 0),
-                row(0, 1, -1, 0, 0),
-                row(0, 1, -1, 1, 0),
-                row(0, 1, -1, 1, 1),
-                row(0, 1, 0, -1, -1),
-                row(0, 1, 0, 0, -1),
-                row(0, 1, 0, 0, 0),
-                row(0, 0, 0, 0, 0)
-        );
-
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) > (?,?,?,?)", 0, 1, 0, 0, 0),
-                row(0, 2, 0, -1, 0),
-                row(0, 2, 0, -1, 1),
-                row(0, 1, 0,  0, 1),
-                row(0, 1, 0,  1, -1),
-                row(0, 1, 0,  1, 1),
-                row(0, 1, 1, -1, 0),
-                row(0, 1, 1,  0, -1),
-                row(0, 1, 1,  0, 0),
-                row(0, 1, 1,  0, 1)
-        );
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) >= (?,?,?,?)", 0, 1, 0, 0, 0),
-                row(0, 2, 0, -1, 0),
-                row(0, 2, 0, -1, 1),
-                row(0, 1, 0,  0, 0),
-                row(0, 1, 0,  0, 1),
-                row(0, 1, 0,  1, -1),
-                row(0, 1, 0,  1, 1),
-                row(0, 1, 1, -1, 0),
-                row(0, 1, 1,  0, -1),
-                row(0, 1, 1,  0, 0),
-                row(0, 1, 1,  0, 1)
-        );
+            // b and d are reversed in the clustering order
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, 0, -1, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, 0, -1, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 0, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 1, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 1, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 1, -1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 1, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, -1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, -1, -1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, -1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, -1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, -1, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 0, 0, 0, 0);
+
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) <= (?,?,?,?)", 0, 1, 0, 0, 0),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 0, 0, 0, 0)
+            );
+
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) > (?,?,?,?)", 0, 1, 0, 0, 0),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1)
+            );
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) >= (?,?,?,?)", 0, 1, 0, 0, 0),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1)
+            );
+        }
     }
 
     @Test
     public void testMixedOrderColumns3() throws Throwable
     {
-        createTable("create table %s (a int, b int, c int, PRIMARY KEY (a, b, c)) WITH CLUSTERING ORDER BY (b DESC, c ASC)");
-
-        execute("INSERT INTO %s (a, b, c) VALUES (?,?,?);", 0, 2, 3);
-        execute("INSERT INTO %s (a, b, c) VALUES (?,?,?);", 0, 2, 4);
-        execute("INSERT INTO %s (a, b, c) VALUES (?,?,?);", 0, 4, 4);
-        execute("INSERT INTO %s (a, b, c) VALUES (?,?,?);", 0, 3, 4);
-        execute("INSERT INTO %s (a, b, c) VALUES (?,?,?);", 0, 4, 5);
-        execute("INSERT INTO %s (a, b, c) VALUES (?,?,?);", 0, 4, 6);
-
-
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c)>=(?,?) AND (b,c)<(?,?) ALLOW FILTERING", 0, 2, 3, 4, 5),
-                row(0, 4, 4), row(0, 3, 4), row(0, 2, 3), row(0, 2, 4)
-        );
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c)>=(?,?) AND (b,c)<=(?,?) ALLOW FILTERING", 0, 2, 3, 4, 5),
-                row(0, 4, 4), row(0, 4, 5), row(0, 3, 4), row(0, 2, 3), row(0, 2, 4)
-        );
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c)<(?,?) ALLOW FILTERING", 0, 4, 5),
-                row(0, 4, 4),row(0, 3, 4),row(0, 2, 3),row(0, 2, 4)
-        );
-
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c)>(?,?) ALLOW FILTERING", 0, 4, 5),
-                row(0, 4, 6)
-        );
-
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b)<(?) and (b)>(?) ALLOW FILTERING", 0, 4, 2),
-                row(0, 3, 4)
-        );
+        for (String compactOption : new String[]{"", " COMPACT STORAGE AND "})
+        {
+            createTable("CREATE TABLE %s (a int, b int, c int, PRIMARY KEY (a, b, c)) WITH " +
+                        compactOption +
+                        "CLUSTERING ORDER BY (b DESC, c ASC)");
+
+            execute("INSERT INTO %s (a, b, c) VALUES (?,?,?);", 0, 2, 3);
+            execute("INSERT INTO %s (a, b, c) VALUES (?,?,?);", 0, 2, 4);
+            execute("INSERT INTO %s (a, b, c) VALUES (?,?,?);", 0, 4, 4);
+            execute("INSERT INTO %s (a, b, c) VALUES (?,?,?);", 0, 3, 4);
+            execute("INSERT INTO %s (a, b, c) VALUES (?,?,?);", 0, 4, 5);
+            execute("INSERT INTO %s (a, b, c) VALUES (?,?,?);", 0, 4, 6);
+
+
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c)>=(?,?) AND (b,c)<(?,?) ALLOW FILTERING", 0, 2, 3, 4, 5),
+                       row(0, 4, 4), row(0, 3, 4), row(0, 2, 3), row(0, 2, 4)
+            );
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c)>=(?,?) AND (b,c)<=(?,?) ALLOW FILTERING", 0, 2, 3, 4, 5),
+                       row(0, 4, 4), row(0, 4, 5), row(0, 3, 4), row(0, 2, 3), row(0, 2, 4)
+            );
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c)<(?,?) ALLOW FILTERING", 0, 4, 5),
+                       row(0, 4, 4), row(0, 3, 4), row(0, 2, 3), row(0, 2, 4)
+            );
+
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c)>(?,?) ALLOW FILTERING", 0, 4, 5),
+                       row(0, 4, 6)
+            );
+
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b)<(?) and (b)>(?) ALLOW FILTERING", 0, 4, 2),
+                       row(0, 3, 4)
+            );
+        }
     }
 
     @Test
     public void testMixedOrderColumns4() throws Throwable
     {
-        createTable("CREATE TABLE %s (a int, b int, c int, d int, e int, PRIMARY KEY (a, b, c, d, e)) " +
-                "WITH CLUSTERING ORDER BY (b ASC, c DESC, d DESC, e ASC)");
-
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, 0, -1, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, 0, -1, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, 0, 1, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, -1, 1, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, -3, 1, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 0, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 1, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 1, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 1, -1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 1, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, -1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, -1, -1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, -1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, -1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 1);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, -1, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 0, 0, 0, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, -1, 0, -1, 0);
-        execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, -1, 0, 0, 0);
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d,e)<(?,?,?,?) " +
-                                "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0, 1, 1, -1, 0, -1, -1),
-
-                row(0, -1, 0, 0, 0),
-                row(0, -1, 0, -1, 0),
-                row(0, 0, 0, 0, 0),
-                row(0, 1, 1, 0, -1),
-                row(0, 1, 1, 0, 0),
-                row(0, 1, 1, 0, 1),
-                row(0, 1, 1, -1, 0),
-                row(0, 1, 0, 1, -1),
-                row(0, 1, 0, 1, 1),
-                row(0, 1, 0, 0, -1),
-                row(0, 1, 0, 0, 0),
-                row(0, 1, 0, 0, 1),
-                row(0, 1, 0, -1, -1),
-                row(0, 1, -1, 1, 0),
-                row(0, 1, -1, 1, 1),
-                row(0, 1, -1, 0, 0),
-                row(0, 2, 0, -1, 0),
-                row(0, 2, 0, -1, 1),
-                row(0, 2, -1, 1, 1),
-                row(0, 2, -3, 1, 1)
-
-        );
-
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d,e) < (?,?,?,?) " +
-                                "AND (b,c,d,e)>(?,?,?,?)", 0, 1, 0, 0, 0, 1, 0, -1, -1),
-                row(0, 1, 0, 0, -1)
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d,e) <= (?,?,?,?) " +
-                                "AND (b,c,d,e)>(?,?,?,?)", 0, 1, 0, 0, 0, 1, 0,-1,-1),
-                row(0, 1, 0, 0, -1),
-                row(0, 1, 0, 0, 0)
-        );
-
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d,e)<=(?,?,?,?) " +
-                                "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0, 1, 1, -1, 0,-1,-1),
-
-                row( 0, -1, 0, 0, 0),
-                row( 0, -1, 0, -1, 0),
-                row(0, 0, 0, 0, 0),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0),
-                row( 0, 1, 1, 0, 1),
-                row( 0, 1, 1, -1, 0),
-                row( 0, 1, 0, 1, -1),
-                row( 0, 1, 0, 1, 1),
-                row( 0, 1, 0, 0, -1),
-                row( 0, 1, 0, 0, 0),
-                row( 0, 1, 0, 0, 1),
-                row( 0, 1, 0, -1, -1),
-                row( 0, 1, -1, 1, 0),
-                row( 0, 1, -1, 1, 1),
-                row( 0, 1, -1, 0, 0),
-                row( 0, 2, 0, 1, 1),
-                row( 0, 2, 0, -1, 0),
-                row( 0, 2, 0, -1, 1),
-                row(  0, 2, -1, 1, 1),
-                row(  0, 2, -3, 1, 1)
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c)<=(?,?) " +
-                                "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0, -1, 0,-1,-1),
-
-                row( 0, -1, 0, 0, 0),
-                row(0, -1, 0, -1, 0),
-                row( 0, 0, 0, 0, 0),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0),
-                row( 0, 1, 1, 0, 1),
-                row( 0, 1, 1, -1, 0),
-                row( 0, 1, 0, 1, -1),
-                row( 0, 1, 0, 1, 1),
-                row( 0, 1, 0, 0, -1),
-                row( 0, 1, 0, 0, 0),
-                row( 0, 1, 0, 0, 1),
-                row( 0, 1, 0, -1, -1),
-                row( 0, 1, -1, 1, 0),
-                row( 0, 1, -1, 1, 1),
-                row( 0, 1, -1, 0, 0),
-                row( 0, 2, 0, 1, 1),
-                row( 0, 2, 0, -1, 0),
-                row( 0, 2, 0, -1, 1),
-                row(  0, 2, -1, 1, 1),
-                row(  0, 2, -3, 1, 1)
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c)<(?,?) " +
-                                "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0, -1, 0, -1, -1),
-                row( 0, -1, 0, 0, 0),
-                row( 0, -1, 0, -1, 0),
-                row( 0, 0, 0, 0, 0),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0),
-                row( 0, 1, 1, 0, 1),
-                row( 0, 1, 1, -1, 0),
-                row( 0, 1, 0, 1, -1),
-                row( 0, 1, 0, 1, 1),
-                row( 0, 1, 0, 0, -1),
-                row( 0, 1, 0, 0, 0),
-                row( 0, 1, 0, 0, 1),
-                row( 0, 1, 0, -1, -1),
-                row( 0, 1, -1, 1, 0),
-                row( 0, 1, -1, 1, 1),
-                row( 0, 1, -1, 0, 0),
-                row(  0, 2, -1, 1, 1),
-                row(0, 2, -3, 1, 1)
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d,e)<=(?,?,?,?) " +
-                                "AND (b)>=(?)", 0, 2, 0, 1, 1, -1),
-
-                row( 0, -1, 0, 0, 0),
-                row( 0, -1, 0, -1, 0),
-                row( 0, 0, 0, 0, 0),
-                row( 0, 1, 1, 0, -1),
-                row(0, 1, 1, 0, 0),
-                row( 0, 1, 1, 0, 1),
-                row( 0, 1, 1, -1, 0),
-                row( 0, 1, 0, 1, -1),
-                row( 0, 1, 0, 1, 1),
-                row( 0, 1, 0, 0, -1),
-                row( 0, 1, 0, 0, 0),
-                row( 0, 1, 0, 0, 1),
-                row( 0, 1, 0, -1, -1),
-                row( 0, 1, -1, 1, 0),
-                row( 0, 1, -1, 1, 1),
-                row( 0, 1, -1, 0, 0),
-                row( 0, 2, 0, 1, 1),
-                row( 0, 2, 0, -1, 0),
-                row( 0, 2, 0, -1, 1),
-                row(  0, 2, -1, 1, 1),
-                row(  0, 2, -3, 1, 1)
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d,e)<=(?,?,?,?) " +
-                                "AND (b)>(?)", 0, 2, 0, 1, 1, -1),
-
-                row( 0, 0, 0, 0, 0),
-                row( 0, 1, 1, 0, -1),
-                row( 0, 1, 1, 0, 0),
-                row( 0, 1, 1, 0, 1),
-                row( 0, 1, 1, -1, 0),
-                row( 0, 1, 0, 1, -1),
-                row( 0, 1, 0, 1, 1),
-                row( 0, 1, 0, 0, -1),
-                row( 0, 1, 0, 0, 0),
-                row( 0, 1, 0, 0, 1),
-                row( 0, 1, 0, -1, -1),
-                row( 0, 1, -1, 1, 0),
-                row( 0, 1, -1, 1, 1),
-                row( 0, 1, -1, 0, 0),
-                row( 0, 2, 0, 1, 1),
-                row( 0, 2, 0, -1, 0),
-                row( 0, 2, 0, -1, 1),
-                row(  0, 2, -1, 1, 1),
-                row(  0, 2, -3, 1, 1)
-        );
-
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) <= (?,?,?,?)", 0, 1, 0, 0, 0),
-                row(0, -1, 0, 0, 0),
-                row(0, -1, 0, -1, 0),
-                row(0, 0, 0, 0, 0),
-                row(0, 1, 0, 0, -1),
-                row(0, 1, 0, 0, 0),
-                row(0, 1, 0, -1, -1),
-                row(0, 1, -1, 1, 0),
-                row(0, 1, -1, 1, 1),
-                row(0, 1, -1, 0, 0)
-        );
-
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) > (?,?,?,?)", 0, 1, 0, 0, 0),
-                row(0, 1, 1,  0, -1),
-                row(0, 1, 1,  0, 0),
-                row(0, 1, 1, 0, 1),
-                row(0, 1, 1, -1, 0),
-                row(0, 1, 0,  1, -1),
-                row(0, 1, 0,  1, 1),
-                row(0, 1, 0,  0, 1),
-                row(0, 2, 0, 1, 1),
-                row(0, 2, 0, -1, 0),
-                row(0, 2, 0, -1, 1),
-                row(  0, 2, -1, 1, 1),
-                row(  0, 2, -3, 1, 1)
-
-        );
-
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) >= (?,?,?,?)", 0, 1, 0, 0, 0),
-                row(0, 1, 1,  0, -1),
-                row(0, 1, 1,  0, 0),
-                row(0, 1, 1, 0, 1),
-                row(0, 1, 1, -1, 0),
-                row(0, 1, 0,  1, -1),
-                row(0, 1, 0,  1, 1),
-                row(0, 1, 0,  0, 0),
-                row(0, 1, 0,  0, 1),
-                row(0, 2, 0, 1, 1),
-                row(0, 2, 0, -1, 0),
-                row(0, 2, 0, -1, 1),
-                row(  0, 2, -1, 1, 1),
-                row(  0, 2, -3, 1, 1)
-        );
-
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d) >= (?,?,?)", 0, 1, 0, 0),
-                row(0, 1, 1,  0, -1),
-                row(0, 1, 1,  0, 0),
-                row(0, 1, 1, 0, 1),
-                row(0, 1, 1, -1, 0),
-                row(0, 1, 0,  1, -1),
-                row(0, 1, 0,  1, 1),
-                row(0, 1, 0,  0, -1),
-                row(0, 1, 0,  0, 0),
-                row(0, 1, 0,  0, 1),
-                row(0, 2, 0, 1, 1),
-                row(0, 2, 0, -1, 0),
-                row(0, 2, 0, -1, 1),
-                row(  0, 2, -1, 1, 1),
-                row(  0, 2, -3, 1, 1)
-        );
-
-        assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d) > (?,?,?)", 0, 1, 0, 0),
-                row(0, 1, 1,  0, -1),
-                row(0, 1, 1,  0, 0),
-                row(0, 1, 1,  0, 1),
-                row(0, 1, 1, -1, 0),
-                row(0, 1, 0,  1, -1),
-                row(0, 1, 0,  1, 1),
-                row(0, 2, 0, 1, 1),
-                row(0, 2, 0, -1, 0),
-                row(0, 2, 0, -1, 1),
-                row(  0, 2, -1, 1, 1),
-                row(  0, 2, -3, 1, 1)
-        );
-
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b) < (?) ", 0, 0),
-                row(0, -1, 0, 0, 0), row(0, -1, 0, -1, 0)
-        );
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b) <= (?) ", 0,-1),
-                row(0, -1, 0, 0, 0), row(0, -1, 0, -1, 0)
-        );
-        assertRows(execute(
-                        "SELECT * FROM %s" +
-                                " WHERE a = ? " +
-                                "AND (b,c,d,e) < (?,?,?,?) and (b,c,d,e) > (?,?,?,?) ", 0, 2, 0, 0, 0, 2, -2, 0, 0),
-                row(0, 2, 0, -1, 0),
-                row(0, 2, 0, -1, 1),
-                row(0, 2, -1, 1, 1)
-        );
+        for (String compactOption : new String[]{"", " COMPACT STORAGE AND "})
+        {
+            createTable("CREATE TABLE %s (a int, b int, c int, d int, e int, PRIMARY KEY (a, b, c, d, e)) WITH " +
+                        compactOption +
+                        "CLUSTERING ORDER BY (b ASC, c DESC, d DESC, e ASC)");
+
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, 0, -1, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, 0, -1, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, 0, 1, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, -1, 1, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, -3, 1, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 0, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 1, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, -1, 1, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 1, -1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 1, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, -1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, 0, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 0, -1, -1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, -1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, -1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 0, 1);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, -1, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 0, 0, 0, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, -1, 0, -1, 0);
+            execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, -1, 0, 0, 0);
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d,e)<(?,?,?,?) " +
+            "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0, 1, 1, -1, 0, -1, -1),
+
+                       row(0, -1, 0, 0, 0),
+                       row(0, -1, 0, -1, 0),
+                       row(0, 0, 0, 0, 0),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 2, -1, 1, 1),
+                       row(0, 2, -3, 1, 1)
+
+            );
+
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d,e) < (?,?,?,?) " +
+            "AND (b,c,d,e)>(?,?,?,?)", 0, 1, 0, 0, 0, 1, 0, -1, -1),
+                       row(0, 1, 0, 0, -1)
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d,e) <= (?,?,?,?) " +
+            "AND (b,c,d,e)>(?,?,?,?)", 0, 1, 0, 0, 0, 1, 0, -1, -1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0)
+            );
+
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d,e)<=(?,?,?,?) " +
+            "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0, 1, 1, -1, 0, -1, -1),
+
+                       row(0, -1, 0, 0, 0),
+                       row(0, -1, 0, -1, 0),
+                       row(0, 0, 0, 0, 0),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 2, 0, 1, 1),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 2, -1, 1, 1),
+                       row(0, 2, -3, 1, 1)
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c)<=(?,?) " +
+            "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0, -1, 0, -1, -1),
+
+                       row(0, -1, 0, 0, 0),
+                       row(0, -1, 0, -1, 0),
+                       row(0, 0, 0, 0, 0),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 2, 0, 1, 1),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 2, -1, 1, 1),
+                       row(0, 2, -3, 1, 1)
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c)<(?,?) " +
+            "AND (b,c,d,e)>(?,?,?,?)", 0, 2, 0, -1, 0, -1, -1),
+                       row(0, -1, 0, 0, 0),
+                       row(0, -1, 0, -1, 0),
+                       row(0, 0, 0, 0, 0),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 2, -1, 1, 1),
+                       row(0, 2, -3, 1, 1)
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d,e)<=(?,?,?,?) " +
+            "AND (b)>=(?)", 0, 2, 0, 1, 1, -1),
+
+                       row(0, -1, 0, 0, 0),
+                       row(0, -1, 0, -1, 0),
+                       row(0, 0, 0, 0, 0),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 2, 0, 1, 1),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 2, -1, 1, 1),
+                       row(0, 2, -3, 1, 1)
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d,e)<=(?,?,?,?) " +
+            "AND (b)>(?)", 0, 2, 0, 1, 1, -1),
+
+                       row(0, 0, 0, 0, 0),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0),
+                       row(0, 2, 0, 1, 1),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 2, -1, 1, 1),
+                       row(0, 2, -3, 1, 1)
+            );
+
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) <= (?,?,?,?)", 0, 1, 0, 0, 0),
+                       row(0, -1, 0, 0, 0),
+                       row(0, -1, 0, -1, 0),
+                       row(0, 0, 0, 0, 0),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, -1, -1),
+                       row(0, 1, -1, 1, 0),
+                       row(0, 1, -1, 1, 1),
+                       row(0, 1, -1, 0, 0)
+            );
+
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) > (?,?,?,?)", 0, 1, 0, 0, 0),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 2, 0, 1, 1),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 2, -1, 1, 1),
+                       row(0, 2, -3, 1, 1)
+
+            );
+
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d,e) >= (?,?,?,?)", 0, 1, 0, 0, 0),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 2, 0, 1, 1),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 2, -1, 1, 1),
+                       row(0, 2, -3, 1, 1)
+            );
+
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d) >= (?,?,?)", 0, 1, 0, 0),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 1, 0, 0, -1),
+                       row(0, 1, 0, 0, 0),
+                       row(0, 1, 0, 0, 1),
+                       row(0, 2, 0, 1, 1),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 2, -1, 1, 1),
+                       row(0, 2, -3, 1, 1)
+            );
+
+            assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b,c,d) > (?,?,?)", 0, 1, 0, 0),
+                       row(0, 1, 1, 0, -1),
+                       row(0, 1, 1, 0, 0),
+                       row(0, 1, 1, 0, 1),
+                       row(0, 1, 1, -1, 0),
+                       row(0, 1, 0, 1, -1),
+                       row(0, 1, 0, 1, 1),
+                       row(0, 2, 0, 1, 1),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 2, -1, 1, 1),
+                       row(0, 2, -3, 1, 1)
+            );
+
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b) < (?) ", 0, 0),
+                       row(0, -1, 0, 0, 0), row(0, -1, 0, -1, 0)
+            );
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b) <= (?) ", 0, -1),
+                       row(0, -1, 0, 0, 0), row(0, -1, 0, -1, 0)
+            );
+            assertRows(execute(
+            "SELECT * FROM %s" +
+            " WHERE a = ? " +
+            "AND (b,c,d,e) < (?,?,?,?) and (b,c,d,e) > (?,?,?,?) ", 0, 2, 0, 0, 0, 2, -2, 0, 0),
+                       row(0, 2, 0, -1, 0),
+                       row(0, 2, 0, -1, 1),
+                       row(0, 2, -1, 1, 1)
+            );
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c8d95553/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
index d444fde..97fdf6a 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectTest.java
@@ -2177,4 +2177,77 @@ public class SelectTest extends CQLTester
                              "SELECT * FROM %s WHERE c CONTAINS KEY ? ALLOW FILTERING",
                              unset());
     }
+
+    /**
+     * Check select with and without compact storage, with different column
+     * order. See CASSANDRA-10988
+     */
+    @Test
+    public void testClusteringOrderWithSlice() throws Throwable
+    {
+        for (String compactOption : new String[] { "", " COMPACT STORAGE AND" })
+        {
+            // non-compound, ASC order
+            createTable("CREATE TABLE %s (a text, b int, PRIMARY KEY (a, b)) WITH" +
+                        compactOption +
+                        " CLUSTERING ORDER BY (b ASC)");
+
+            execute("INSERT INTO %s (a, b) VALUES ('a', 2)");
+            execute("INSERT INTO %s (a, b) VALUES ('a', 3)");
+            assertRows(execute("SELECT * FROM %s WHERE a = 'a' AND b > 0"),
+                       row("a", 2),
+                       row("a", 3));
+
+            assertRows(execute("SELECT * FROM %s WHERE a = 'a' AND b > 0 ORDER BY b DESC"),
+                       row("a", 3),
+                       row("a", 2));
+
+            // non-compound, DESC order
+            createTable("CREATE TABLE %s (a text, b int, PRIMARY KEY (a, b)) WITH" +
+                        compactOption +
+                        " CLUSTERING ORDER BY (b DESC)");
+
+            execute("INSERT INTO %s (a, b) VALUES ('a', 2)");
+            execute("INSERT INTO %s (a, b) VALUES ('a', 3)");
+            assertRows(execute("SELECT * FROM %s WHERE a = 'a' AND b > 0"),
+                       row("a", 3),
+                       row("a", 2));
+
+            assertRows(execute("SELECT * FROM %s WHERE a = 'a' AND b > 0 ORDER BY b ASC"),
+                       row("a", 2),
+                       row("a", 3));
+
+            // compound, first column DESC order
+            createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b, c)) WITH" +
+                        compactOption +
+                        " CLUSTERING ORDER BY (b DESC)"
+            );
+
+            execute("INSERT INTO %s (a, b, c) VALUES ('a', 2, 4)");
+            execute("INSERT INTO %s (a, b, c) VALUES ('a', 3, 5)");
+            assertRows(execute("SELECT * FROM %s WHERE a = 'a' AND b > 0"),
+                       row("a", 3, 5),
+                       row("a", 2, 4));
+
+            assertRows(execute("SELECT * FROM %s WHERE a = 'a' AND b > 0 ORDER BY b ASC"),
+                       row("a", 2, 4),
+                       row("a", 3, 5));
+
+            // compound, mixed order
+            createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b, c)) WITH" +
+                        compactOption +
+                        " CLUSTERING ORDER BY (b ASC, c DESC)"
+            );
+
+            execute("INSERT INTO %s (a, b, c) VALUES ('a', 2, 4)");
+            execute("INSERT INTO %s (a, b, c) VALUES ('a', 3, 5)");
+            assertRows(execute("SELECT * FROM %s WHERE a = 'a' AND b > 0"),
+                       row("a", 2, 4),
+                       row("a", 3, 5));
+
+            assertRows(execute("SELECT * FROM %s WHERE a = 'a' AND b > 0 ORDER BY b ASC"),
+                       row("a", 2, 4),
+                       row("a", 3, 5));
+        }
+    }
 }


Mime
View raw message