You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ty...@apache.org on 2015/02/19 20:24:10 UTC

[1/3] cassandra git commit: Fix token() + multi-column relation on clustering cols

Repository: cassandra
Updated Branches:
  refs/heads/trunk 149a152fc -> aef76ddac


Fix token() + multi-column relation on clustering cols

Patch by Tyler Hobbs; reviewed by Benjamin Lerer for CASSANDRA-8797


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

Branch: refs/heads/trunk
Commit: ee160a971a52134a7d2715cb1123472f539c0ace
Parents: 6214e35
Author: Tyler Hobbs <ty...@datastax.com>
Authored: Thu Feb 19 13:16:56 2015 -0600
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Thu Feb 19 13:16:56 2015 -0600

----------------------------------------------------------------------
 CHANGES.txt                                              |  2 ++
 src/java/org/apache/cassandra/cql3/Relation.java         |  5 +++++
 .../org/apache/cassandra/cql3/SingleColumnRelation.java  |  5 +++++
 .../cassandra/cql3/statements/SelectStatement.java       |  6 +++++-
 .../cassandra/cql3/SelectWithTokenFunctionTest.java      | 11 +++++++++++
 5 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ee160a97/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 09d6d2f..f2b4469 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.0.13:
+ * Fix combining token() function with multi-column relations on
+   clustering columns (CASSANDRA-8797)
  * Make CFS.markReferenced() resistant to bad refcounting (CASSANDRA-8829)
  * Fix StreamTransferTask abort/complete bad refcounting (CASSANDRA-8815)
  * Fix AssertionError when querying a DESC clustering ordered

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ee160a97/src/java/org/apache/cassandra/cql3/Relation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Relation.java b/src/java/org/apache/cassandra/cql3/Relation.java
index 0f1366d..e7c5f2d 100644
--- a/src/java/org/apache/cassandra/cql3/Relation.java
+++ b/src/java/org/apache/cassandra/cql3/Relation.java
@@ -54,4 +54,9 @@ public abstract class Relation {
     }
 
     public abstract boolean isMultiColumn();
+
+    public boolean isOnToken()
+    {
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ee160a97/src/java/org/apache/cassandra/cql3/SingleColumnRelation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/SingleColumnRelation.java b/src/java/org/apache/cassandra/cql3/SingleColumnRelation.java
index d63493e..388d938 100644
--- a/src/java/org/apache/cassandra/cql3/SingleColumnRelation.java
+++ b/src/java/org/apache/cassandra/cql3/SingleColumnRelation.java
@@ -84,6 +84,11 @@ public class SingleColumnRelation extends Relation
         return false;
     }
 
+    public boolean isOnToken()
+    {
+        return onToken;
+    }
+
     public SingleColumnRelation withNonStrictOperator()
     {
         switch (relationType)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ee160a97/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 2fa57b9..59ed6e1 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@ -1906,8 +1906,12 @@ public class SelectStatement implements CQLStatement, MeasurableForPreparedCache
             Iterator<Name> iter = Iterators.cycle(cfDef.partitionKeys());
             for (Relation relation : whereClause)
             {
+                if (!relation.isOnToken())
+                    continue;
+
+                assert !relation.isMultiColumn() : "Unexpectedly got multi-column token relation";
                 SingleColumnRelation singleColumnRelation = (SingleColumnRelation) relation;
-                if (singleColumnRelation.onToken && !cfDef.get(singleColumnRelation.getEntity().prepare(cfDef.cfm)).equals(iter.next()))
+                if (!cfDef.get(singleColumnRelation.getEntity().prepare(cfDef.cfm)).equals(iter.next()))
                     throw new InvalidRequestException(String.format("The token function arguments must be in the partition key order: %s",
                                                                     Joiner.on(',').join(cfDef.partitionKeys())));
             }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ee160a97/test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java b/test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java
index 9199862..c222f35 100644
--- a/test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java
+++ b/test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java
@@ -47,6 +47,7 @@ public class SelectWithTokenFunctionTest
         executeSchemaChange("CREATE TABLE IF NOT EXISTS %s.single_partition (a int PRIMARY KEY, b text)");
         executeSchemaChange("CREATE TABLE IF NOT EXISTS %s.compound_partition (a int, b text, PRIMARY KEY ((a, b)))");
         executeSchemaChange("CREATE TABLE IF NOT EXISTS %s.single_clustering (a int, b text, PRIMARY KEY (a, b))");
+        executeSchemaChange("CREATE TABLE IF NOT EXISTS %s.compound_with_clustering (a int, b int, c int, d int, PRIMARY KEY ((a, b), c, d))");
         clientState = ClientState.forInternalCalls();
     }
 
@@ -168,4 +169,14 @@ public class SelectWithTokenFunctionTest
     {
         execute("SELECT * FROM %s.compound_partition WHERE token(a) > token(0) and token(b) > token('c')");
     }
+
+    @Test
+    public void testTokenFunctionWithCompoundPartitionAndClusteringCols() throws Throwable
+    {
+        // just test that the queries don't error
+        execute("SELECT * FROM %s.compound_with_clustering WHERE token(a, b) > token(0, 0) AND c > 10 ALLOW FILTERING;");
+        execute("SELECT * FROM %s.compound_with_clustering WHERE c > 10 AND token(a, b) > token(0, 0) ALLOW FILTERING;");
+        execute("SELECT * FROM %s.compound_with_clustering WHERE token(a, b) > token(0, 0) AND (c, d) > (0, 0) ALLOW FILTERING;");
+        execute("SELECT * FROM %s.compound_with_clustering WHERE (c, d) > (0, 0) AND token(a, b) > token(0, 0) ALLOW FILTERING;");
+    }
 }


[2/3] cassandra git commit: Merge branch 'cassandra-2.0' into cassandra-2.1

Posted by ty...@apache.org.
Merge branch 'cassandra-2.0' into cassandra-2.1

Conflicts:
	CHANGES.txt
	src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
	test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java


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

Branch: refs/heads/trunk
Commit: e4980b3b8df0d15aef0f9f24159064c7be86d111
Parents: 6065f2c ee160a9
Author: Tyler Hobbs <ty...@datastax.com>
Authored: Thu Feb 19 13:21:02 2015 -0600
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Thu Feb 19 13:21:02 2015 -0600

----------------------------------------------------------------------
 CHANGES.txt                                              |  2 ++
 src/java/org/apache/cassandra/cql3/Relation.java         |  5 +++++
 .../org/apache/cassandra/cql3/SingleColumnRelation.java  |  5 +++++
 .../cassandra/cql3/statements/SelectStatement.java       |  6 +++++-
 .../cassandra/cql3/SelectWithTokenFunctionTest.java      | 11 +++++++++++
 5 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e4980b3b/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 9458627,f2b4469..3b6ce5d
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,19 -1,6 +1,21 @@@
 -2.0.13:
 +2.1.4
 + * Fix CommitLog.forceRecycleAllSegments() memory access error (CASSANDRA-8812)
 + * Improve assertions in Memory (CASSANDRA-8792)
 + * Fix SSTableRewriter cleanup (CASSANDRA-8802)
 + * Introduce SafeMemory for CompressionMetadata.Writer (CASSANDRA-8758)
 + * 'nodetool info' prints exception against older node (CASSANDRA-8796)
 + * Ensure SSTableReader.last corresponds exactly with the file end (CASSANDRA-8750)
 + * Make SSTableWriter.openEarly more robust and obvious (CASSANDRA-8747)
 + * Enforce SSTableReader.first/last (CASSANDRA-8744)
 + * Cleanup SegmentedFile API (CASSANDRA-8749)
 + * Avoid overlap with early compaction replacement (CASSANDRA-8683)
 + * Safer Resource Management++ (CASSANDRA-8707)
 + * Write partition size estimates into a system table (CASSANDRA-7688)
 + * cqlsh: Fix keys() and full() collection indexes in DESCRIBE output
 +   (CASSANDRA-8154)
 +Merged from 2.0:
+  * Fix combining token() function with multi-column relations on
+    clustering columns (CASSANDRA-8797)
   * Make CFS.markReferenced() resistant to bad refcounting (CASSANDRA-8829)
   * Fix StreamTransferTask abort/complete bad refcounting (CASSANDRA-8815)
   * Fix AssertionError when querying a DESC clustering ordered

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e4980b3b/src/java/org/apache/cassandra/cql3/Relation.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e4980b3b/src/java/org/apache/cassandra/cql3/SingleColumnRelation.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e4980b3b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
index 08777c7,59ed6e1..9099ba7
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@@ -1933,18 -1898,22 +1933,22 @@@ public class SelectStatement implement
          /**
           * Checks that the column identifiers used as argument for the token function have been specified in the
           * partition key order.
 -         * @param cfDef the Column Family Definition
 +         * @param cfm the Column Family MetaData
           * @throws InvalidRequestException if the arguments have not been provided in the proper order.
           */
 -        private void checkTokenFunctionArgumentsOrder(CFDefinition cfDef) throws InvalidRequestException
 +        private void checkTokenFunctionArgumentsOrder(CFMetaData cfm) throws InvalidRequestException
          {
 -            Iterator<Name> iter = Iterators.cycle(cfDef.partitionKeys());
 +            Iterator<ColumnDefinition> iter = Iterators.cycle(cfm.partitionKeyColumns());
              for (Relation relation : whereClause)
              {
+                 if (!relation.isOnToken())
+                     continue;
+ 
+                 assert !relation.isMultiColumn() : "Unexpectedly got multi-column token relation";
                  SingleColumnRelation singleColumnRelation = (SingleColumnRelation) relation;
-                 if (singleColumnRelation.onToken && !cfm.getColumnDefinition(singleColumnRelation.getEntity().prepare(cfm)).equals(iter.next()))
 -                if (!cfDef.get(singleColumnRelation.getEntity().prepare(cfDef.cfm)).equals(iter.next()))
++                if (!cfm.getColumnDefinition(singleColumnRelation.getEntity().prepare(cfm)).equals(iter.next()))
                      throw new InvalidRequestException(String.format("The token function arguments must be in the partition key order: %s",
 -                                                                    Joiner.on(',').join(cfDef.partitionKeys())));
 +                                                                    Joiner.on(',').join(cfm.partitionKeyColumns())));
              }
          }
  

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e4980b3b/test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java
index 6f9f5e2,c222f35..b2a972b
--- a/test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java
+++ b/test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java
@@@ -44,23 -138,45 +44,34 @@@ public class SelectWithTokenFunctionTes
      }
  
      @Test
 -    public void testTokenFunctionWithCompoundPartition() throws Throwable
 -    {
 -        execute("INSERT INTO %s.compound_partition (a, b) VALUES (0, 'a')");
 -        execute("INSERT INTO %s.compound_partition (a, b) VALUES (0, 'b')");
 -        execute("INSERT INTO %s.compound_partition (a, b) VALUES (0, 'c')");
 -
 -        try
 -        {
 -            UntypedResultSet results = execute("SELECT * FROM %s.compound_partition WHERE token(a, b) > token(0, 'a')");
 -            assertEquals(2, results.size());
 -            results = execute("SELECT * FROM %s.compound_partition WHERE token(a, b) > token(0, 'a') "
 -                    + "and token(a, b) < token(0, 'd')");
 -            assertEquals(2, results.size());
 -        }
 -        finally
 -        {
 -            execute("DELETE FROM %s.compound_partition WHERE a = 0 and b in ('a', 'b', 'c')");
 -        }
 -    }
 -
 -    @Test(expected = InvalidRequestException.class)
 -    public void testTokenFunctionWithCompoundPartitionKeyAndColumnIdentifierInWrongOrder() throws Throwable
 -    {
 -        execute("SELECT * FROM %s.compound_partition WHERE token(b, a) > token(0, 'c')");
 -    }
 -
 -    @Test(expected = InvalidRequestException.class)
 -    public void testTokenFunctionOnEachPartitionKeyColumns() throws Throwable
 +    public void testTokenFunctionWithMultiColumnPartitionKey() throws Throwable
      {
 -        execute("SELECT * FROM %s.compound_partition WHERE token(a) > token(0) and token(b) > token('c')");
 +        createTable("CREATE TABLE IF NOT EXISTS %s (a int, b text, PRIMARY KEY ((a, b)))");
 +        execute("INSERT INTO %s (a, b) VALUES (0, 'a')");
 +        execute("INSERT INTO %s (a, b) VALUES (0, 'b')");
 +        execute("INSERT INTO %s (a, b) VALUES (0, 'c')");
 +
 +        assertRows(execute("SELECT * FROM %s WHERE token(a, b) > token(?, ?)", 0, "a"),
 +                   row(0, "b"),
 +                   row(0, "c"));
 +        assertRows(execute("SELECT * FROM %s WHERE token(a, b) > token(?, ?) and token(a, b) < token(?, ?)",
 +                           0, "a",
 +                           0, "d"),
 +                   row(0, "b"),
 +                   row(0, "c"));
 +        assertInvalid("SELECT * FROM %s WHERE token(a) > token(?) and token(b) > token(?)", 0, "a");
 +        assertInvalid("SELECT * FROM %s WHERE token(a) > token(?, ?) and token(a) < token(?, ?) and token(b) > token(?, ?) ", 0, "a", 0, "d", 0, "a");
 +        assertInvalid("SELECT * FROM %s WHERE token(b, a) > token(0, 'c')");
      }
+ 
+     @Test
+     public void testTokenFunctionWithCompoundPartitionAndClusteringCols() throws Throwable
+     {
++        createTable("CREATE TABLE IF NOT EXISTS %s (a int, b int, c int, d int, PRIMARY KEY ((a, b), c, d))");
+         // just test that the queries don't error
 -        execute("SELECT * FROM %s.compound_with_clustering WHERE token(a, b) > token(0, 0) AND c > 10 ALLOW FILTERING;");
 -        execute("SELECT * FROM %s.compound_with_clustering WHERE c > 10 AND token(a, b) > token(0, 0) ALLOW FILTERING;");
 -        execute("SELECT * FROM %s.compound_with_clustering WHERE token(a, b) > token(0, 0) AND (c, d) > (0, 0) ALLOW FILTERING;");
 -        execute("SELECT * FROM %s.compound_with_clustering WHERE (c, d) > (0, 0) AND token(a, b) > token(0, 0) ALLOW FILTERING;");
++        execute("SELECT * FROM %s WHERE token(a, b) > token(0, 0) AND c > 10 ALLOW FILTERING;");
++        execute("SELECT * FROM %s WHERE c > 10 AND token(a, b) > token(0, 0) ALLOW FILTERING;");
++        execute("SELECT * FROM %s WHERE token(a, b) > token(0, 0) AND (c, d) > (0, 0) ALLOW FILTERING;");
++        execute("SELECT * FROM %s WHERE (c, d) > (0, 0) AND token(a, b) > token(0, 0) ALLOW FILTERING;");
+     }
  }


[3/3] cassandra git commit: Merge branch 'cassandra-2.1' into trunk

Posted by ty...@apache.org.
Merge branch 'cassandra-2.1' into trunk


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

Branch: refs/heads/trunk
Commit: aef76ddac3fb2989e299f044a46ab55c679ec288
Parents: 149a152 e4980b3
Author: Tyler Hobbs <ty...@datastax.com>
Authored: Thu Feb 19 13:23:57 2015 -0600
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Thu Feb 19 13:23:57 2015 -0600

----------------------------------------------------------------------
 CHANGES.txt                                             |  2 ++
 .../cassandra/cql3/SelectWithTokenFunctionTest.java     | 12 ++++++++++++
 2 files changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/aef76dda/CHANGES.txt
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/aef76dda/test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java
index a365c09,b2a972b..b674ba2
--- a/test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java
+++ b/test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java
@@@ -74,149 -59,19 +74,161 @@@ public class SelectWithTokenFunctionTes
                             0, "d"),
                     row(0, "b"),
                     row(0, "c"));
 -        assertInvalid("SELECT * FROM %s WHERE token(a) > token(?) and token(b) > token(?)", 0, "a");
 -        assertInvalid("SELECT * FROM %s WHERE token(a) > token(?, ?) and token(a) < token(?, ?) and token(b) > token(?, ?) ", 0, "a", 0, "d", 0, "a");
 -        assertInvalid("SELECT * FROM %s WHERE token(b, a) > token(0, 'c')");
 +        assertInvalidMessage("The token() function must be applied to all partition key components or none of them",
 +                             "SELECT * FROM %s WHERE token(a) > token(?) and token(b) > token(?)", 0, "a");
 +        assertInvalidMessage("The token() function must be applied to all partition key components or none of them",
 +                             "SELECT * FROM %s WHERE token(a) > token(?, ?) and token(a) < token(?, ?) and token(b) > token(?, ?) ",
 +                             0, "a", 0, "d", 0, "a");
 +        assertInvalidMessage("The token function arguments must be in the partition key order: a, b",
 +                             "SELECT * FROM %s WHERE token(b, a) > token(0, 'c')");
 +        assertInvalidMessage("The token() function must be applied to all partition key components or none of them",
 +                             "SELECT * FROM %s WHERE token(a, b) > token(?, ?) and token(b) < token(?, ?)", 0, "a", 0, "a");
 +        assertInvalidMessage("The token() function must be applied to all partition key components or none of them",
 +                             "SELECT * FROM %s WHERE token(a) > token(?, ?) and token(b) > token(?, ?)", 0, "a", 0, "a");
 +    }
 +
 +    @Test
 +    public void testSingleColumnPartitionKeyWithTokenNonTokenRestrictionsMix() throws Throwable
 +    {
 +        createTable("CREATE TABLE %s (a int primary key, b int)");
 +
 +        execute("INSERT INTO %s (a, b) VALUES (0, 0);");
 +        execute("INSERT INTO %s (a, b) VALUES (1, 1);");
 +        execute("INSERT INTO %s (a, b) VALUES (2, 2);");
 +        execute("INSERT INTO %s (a, b) VALUES (3, 3);");
 +        execute("INSERT INTO %s (a, b) VALUES (4, 4);");
 +        assertRows(execute("SELECT * FROM %s WHERE a IN (?, ?);", 1, 3),
 +                   row(1, 1),
 +                   row(3, 3));
 +        assertRows(execute("SELECT * FROM %s WHERE token(a)> token(?) and token(a) <= token(?);", 1, 3),
 +                   row(2, 2),
 +                   row(3, 3));
 +        assertRows(execute("SELECT * FROM %s WHERE token(a)= token(2);"),
 +                   row(2, 2));
 +        assertRows(execute("SELECT * FROM %s WHERE token(a) > token(?) AND token(a) <= token(?) AND a IN (?, ?);",
 +                           1, 3, 1, 3),
 +                   row(3, 3));
 +        assertRows(execute("SELECT * FROM %s WHERE token(a) < token(?) AND token(a) >= token(?) AND a IN (?, ?);",
 +                           1, 3, 1, 3),
 +                   row(3, 3));
 +        assertInvalidMessage("Only EQ and IN relation are supported on the partition key (unless you use the token() function)",
 +                             "SELECT * FROM %s WHERE token(a) > token(?) AND token(a) <= token(?) AND a > ?;", 1, 3, 1);
 +
 +        assertRows(execute("SELECT * FROM %s WHERE token(a) > token(?) AND token(a) <= token(?) AND a IN ?;",
 +                           1, 3, Arrays.asList(1, 3)),
 +                   row(3, 3));
 +        assertRows(execute("SELECT * FROM %s WHERE token(a) > token(?) AND a = ?;", 1, 3),
 +                   row(3, 3));
 +        assertRows(execute("SELECT * FROM %s WHERE a = ? AND token(a) > token(?);", 3, 1),
 +                   row(3, 3));
 +        assertEmpty(execute("SELECT * FROM %s WHERE token(a) > token(?) AND a = ?;", 3, 1));
 +        assertEmpty(execute("SELECT * FROM %s WHERE a = ? AND token(a) > token(?);", 1, 3));
 +        assertRows(execute("SELECT * FROM %s WHERE token(a) > token(?) AND a IN (?, ?);", 2, 1, 3),
 +                   row(3, 3));
 +        assertRows(execute("SELECT * FROM %s WHERE token(a) > token(?) AND token(a) < token(?) AND a IN (?, ?) ;", 2, 5, 1, 3),
 +                   row(3, 3));
 +        assertRows(execute("SELECT * FROM %s WHERE a IN (?, ?) AND token(a) > token(?) AND token(a) < token(?);", 1, 3, 2, 5),
 +                   row(3, 3));
 +        assertRows(execute("SELECT * FROM %s WHERE token(a) > token(?) AND a IN (?, ?) AND token(a) < token(?);", 2, 1, 3, 5),
 +                   row(3, 3));
 +        assertEmpty(execute("SELECT * FROM %s WHERE a IN (?, ?) AND token(a) > token(?);", 1, 3, 3));
 +        assertRows(execute("SELECT * FROM %s WHERE token(a) <= token(?) AND a = ?;", 2, 2),
 +                   row(2, 2));
 +        assertEmpty(execute("SELECT * FROM %s WHERE token(a) <= token(?) AND a = ?;", 2, 3));
 +        assertEmpty(execute("SELECT * FROM %s WHERE token(a) = token(?) AND a = ?;", 2, 3));
 +        assertRows(execute("SELECT * FROM %s WHERE token(a) >= token(?) AND token(a) <= token(?) AND a = ?;", 2, 2, 2),
 +                   row(2, 2));
 +        assertEmpty(execute("SELECT * FROM %s WHERE token(a) >= token(?) AND token(a) < token(?) AND a = ?;", 2, 2, 2));
 +        assertEmpty(execute("SELECT * FROM %s WHERE token(a) > token(?) AND token(a) <= token(?) AND a = ?;", 2, 2, 2));
 +        assertEmpty(execute("SELECT * FROM %s WHERE token(a) > token(?) AND token(a) < token(?) AND a = ?;", 2, 2, 2));
 +    }
 +
 +    @Test
 +    public void testMultiColumnPartitionKeyWithTokenNonTokenRestrictionsMix() throws Throwable
 +    {
 +        createTable("CREATE TABLE %s (a int, b int, c int, primary key((a, b)))");
 +
 +        execute("INSERT INTO %s (a, b, c) VALUES (0, 0, 0);");
 +        execute("INSERT INTO %s (a, b, c) VALUES (0, 1, 1);");
 +        execute("INSERT INTO %s (a, b, c) VALUES (0, 2, 2);");
 +        execute("INSERT INTO %s (a, b, c) VALUES (1, 0, 3);");
 +        execute("INSERT INTO %s (a, b, c) VALUES (1, 1, 4);");
 +
 +        assertRows(execute("SELECT * FROM %s WHERE token(a, b) > token(?, ?);", 0, 0),
 +                   row(0, 1, 1),
 +                   row(0, 2, 2),
 +                   row(1, 0, 3),
 +                   row(1, 1, 4));
 +
 +        assertRows(execute("SELECT * FROM %s WHERE token(a, b) > token(?, ?) AND a = ? AND b IN (?, ?);",
 +                           0, 0, 1, 0, 1),
 +                   row(1, 0, 3),
 +                   row(1, 1, 4));
 +
 +        assertRows(execute("SELECT * FROM %s WHERE a = ? AND token(a, b) > token(?, ?) AND b IN (?, ?);",
 +                           1, 0, 0, 0, 1),
 +                   row(1, 0, 3),
 +                   row(1, 1, 4));
 +
 +        assertRows(execute("SELECT * FROM %s WHERE b IN (?, ?) AND token(a, b) > token(?, ?) AND a = ?;",
 +                           0, 1, 0, 0, 1),
 +                   row(1, 0, 3),
 +                   row(1, 1, 4));
 +
 +        assertEmpty(execute("SELECT * FROM %s WHERE b IN (?, ?) AND token(a, b) > token(?, ?) AND token(a, b) < token(?, ?) AND a = ?;",
 +                            0, 1, 0, 0, 0, 0, 1));
 +
 +        assertEmpty(execute("SELECT * FROM %s WHERE b IN (?, ?) AND token(a, b) > token(?, ?) AND token(a, b) <= token(?, ?) AND a = ?;",
 +                            0, 1, 0, 0, 0, 0, 1));
 +
 +        assertEmpty(execute("SELECT * FROM %s WHERE b IN (?, ?) AND token(a, b) >= token(?, ?) AND token(a, b) < token(?, ?) AND a = ?;",
 +                            0, 1, 0, 0, 0, 0, 1));
 +
 +        assertEmpty(execute("SELECT * FROM %s WHERE b IN (?, ?) AND token(a, b) = token(?, ?) AND a = ?;",
 +                            0, 1, 0, 0, 1));
 +
 +        assertInvalidMessage("Partition key parts: b must be restricted as other parts are",
 +                             "SELECT * FROM %s WHERE token(a, b) > token(?, ?) AND a = ?;", 0, 0, 1);
 +    }
 +
 +    @Test
 +    public void testMultiColumnPartitionKeyWithIndexAndTokenNonTokenRestrictionsMix() throws Throwable
 +    {
 +        createTable("CREATE TABLE %s (a int, b int, c int, primary key((a, b)))");
 +        createIndex("CREATE INDEX ON %s(b)");
 +        createIndex("CREATE INDEX ON %s(c)");
 +
 +        execute("INSERT INTO %s (a, b, c) VALUES (0, 0, 0);");
 +        execute("INSERT INTO %s (a, b, c) VALUES (0, 1, 1);");
 +        execute("INSERT INTO %s (a, b, c) VALUES (0, 2, 2);");
 +        execute("INSERT INTO %s (a, b, c) VALUES (1, 0, 3);");
 +        execute("INSERT INTO %s (a, b, c) VALUES (1, 1, 4);");
 +
 +        assertRows(execute("SELECT * FROM %s WHERE b = ?;", 1),
 +                   row(0, 1, 1),
 +                   row(1, 1, 4));
 +
 +        assertRows(execute("SELECT * FROM %s WHERE token(a, b) > token(?, ?) AND b = ?;", 0, 0, 1),
 +                   row(0, 1, 1),
 +                   row(1, 1, 4));
 +
 +        assertRows(execute("SELECT * FROM %s WHERE b = ? AND token(a, b) > token(?, ?);", 1, 0, 0),
 +                   row(0, 1, 1),
 +                   row(1, 1, 4));
 +
 +        assertRows(execute("SELECT * FROM %s WHERE b = ? AND token(a, b) > token(?, ?) and c = ? ALLOW FILTERING;", 1, 0, 0, 4),
 +                   row(1, 1, 4));
      }
+ 
+     @Test
+     public void testTokenFunctionWithCompoundPartitionAndClusteringCols() throws Throwable
+     {
+         createTable("CREATE TABLE IF NOT EXISTS %s (a int, b int, c int, d int, PRIMARY KEY ((a, b), c, d))");
+         // just test that the queries don't error
++        // note: these shouldn't require ALLOW FILTERING
+         execute("SELECT * FROM %s WHERE token(a, b) > token(0, 0) AND c > 10 ALLOW FILTERING;");
+         execute("SELECT * FROM %s WHERE c > 10 AND token(a, b) > token(0, 0) ALLOW FILTERING;");
+         execute("SELECT * FROM %s WHERE token(a, b) > token(0, 0) AND (c, d) > (0, 0) ALLOW FILTERING;");
+         execute("SELECT * FROM %s WHERE (c, d) > (0, 0) AND token(a, b) > token(0, 0) ALLOW FILTERING;");
+     }
  }