Merge branch 'cassandra-2.1' into cassandra-2.2
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/2a4ab871 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/2a4ab871 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/2a4ab871 Branch: refs/heads/cassandra-2.2 Commit: 2a4ab8716a8aa4f80a91b3128ecbe9ab6e764ddc Parents: 239927d 2c58581 Author: Tyler Hobbs <[email protected]> Authored: Fri Jun 26 14:57:27 2015 -0500 Committer: Tyler Hobbs <[email protected]> Committed: Fri Jun 26 14:57:27 2015 -0500 ---------------------------------------------------------------------- .../SelectMultiColumnRelationTest.java | 29 ++++++++++++++++++++ .../SelectSingleColumnRelationTest.java | 8 ++++++ 2 files changed, 37 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/2a4ab871/test/unit/org/apache/cassandra/cql3/validation/operations/SelectMultiColumnRelationTest.java ---------------------------------------------------------------------- diff --cc test/unit/org/apache/cassandra/cql3/validation/operations/SelectMultiColumnRelationTest.java index 552e39e,954f89d..39412b9 --- a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectMultiColumnRelationTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectMultiColumnRelationTest.java @@@ -791,26 -738,20 +795,33 @@@ public class SelectMultiColumnRelationT row(0, 1, 0, 0, 0), row(0, 1, 1, 0, 1), row(0, 1, 1, 1, 2)); + + assertInvalidMessage("Cannot execute this query as it might involve data filtering", + "SELECT * FROM %s WHERE (b, c) = (?, ?)", 1, 1); + assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c) = (?, ?)", 0, 1, 1), + row(0, 1, 1, 0, 1), + row(0, 1, 1, 1, 2)); assertRows(execute("SELECT * FROM %s WHERE (b, c) = (?, ?) ALLOW FILTERING", 1, 1), row(0, 1, 1, 0, 1), row(0, 1, 1, 1, 2)); + + assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c) = (?, ?) AND e = ?", 0, 1, 1, 2), + row(0, 1, 1, 1, 2)); + assertInvalidMessage("Cannot execute this query as it might involve data filtering", + "SELECT * FROM %s WHERE (b, c) = (?, ?) AND e = ?", 1, 1, 2); assertRows(execute("SELECT * FROM %s WHERE (b, c) = (?, ?) AND e = ? ALLOW FILTERING", 1, 1, 2), row(0, 1, 1, 1, 2)); - assertRows(execute("SELECT * FROM %s WHERE (b) IN ((?)) AND e = ? ", 1, 2), + ++ assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) IN ((?)) AND e = ? ALLOW FILTERING", 0, 1, 2), ++ row(0, 1, 1, 1, 2)); + assertInvalidMessage("Cannot execute this query as it might involve data filtering", + "SELECT * FROM %s WHERE (b) IN ((?)) AND e = ?", 1, 2); + assertRows(execute("SELECT * FROM %s WHERE (b) IN ((?)) AND e = ? ALLOW FILTERING", 1, 2), row(0, 1, 1, 1, 2)); - assertRows(execute("SELECT * FROM %s WHERE (b) IN ((?), (?)) AND e = ?", 0, 1, 2), + assertInvalidMessage("Cannot execute this query as it might involve data filtering", + "SELECT * FROM %s WHERE (b) IN ((?), (?)) AND e = ?", 0, 1, 2); + assertRows(execute("SELECT * FROM %s WHERE (b) IN ((?), (?)) AND e = ? ALLOW FILTERING", 0, 1, 2), row(0, 0, 1, 1, 2), row(0, 1, 1, 1, 2)); @@@ -825,15 -762,12 +836,16 @@@ row(0, 0, 1, 1, 2), row(0, 1, 1, 1, 2)); - assertRows(execute("SELECT * FROM %s WHERE (b) >= (?) AND e = ?", 1, 2), + assertInvalidMessage("Cannot execute this query as it might involve data filtering", + "SELECT * FROM %s WHERE (b) >= (?) AND e = ?", 1, 2); + assertRows(execute("SELECT * FROM %s WHERE (b) >= (?) AND e = ? ALLOW FILTERING", 1, 2), row(0, 1, 1, 1, 2)); - assertRows(execute("SELECT * FROM %s WHERE (b, c) >= (?, ?) AND e = ?", 1, 1, 2), + assertInvalidMessage("Cannot execute this query as it might involve data filtering", + "SELECT * FROM %s WHERE (b, c) >= (?, ?) AND e = ?", 1, 1, 2); + assertRows(execute("SELECT * FROM %s WHERE (b, c) >= (?, ?) AND e = ? ALLOW FILTERING", 1, 1, 2), row(0, 1, 1, 1, 2)); + } @Test @@@ -866,36 -796,44 +878,53 @@@ row(0, 0, 1, 1, 0, 4), row(0, 0, 1, 1, 1, 5)); - assertInvalidMessage("Partition key part b must be restricted since preceding part is", + assertInvalidMessage("Partition key parts: b must be restricted as other parts are", "SELECT * FROM %s WHERE a = ? AND (c, d) IN ((?, ?)) ALLOW FILTERING", 0, 1, 1); - assertInvalidMessage("Partition key part b must be restricted since preceding part is", + assertInvalidMessage("Partition key parts: b must be restricted as other parts are", "SELECT * FROM %s WHERE a = ? AND (c, d) >= (?, ?) ALLOW FILTERING", 0, 1, 1); + assertRows(execute("SELECT * FROM %s WHERE a = ? AND b = ? AND (c) IN ((?)) AND f = ?", 0, 0, 1, 5), + row(0, 0, 1, 1, 1, 5)); - + assertInvalidMessage("Cannot execute this query as it might involve data filtering", + "SELECT * FROM %s WHERE a = ? AND (c) IN ((?)) AND f = ?", 0, 1, 5); assertRows(execute("SELECT * FROM %s WHERE a = ? AND (c) IN ((?)) AND f = ? ALLOW FILTERING", 0, 1, 5), row(0, 0, 1, 1, 1, 5)); + assertInvalidMessage("Cannot execute this query as it might involve data filtering", + "SELECT * FROM %s WHERE a = ? AND (c) IN ((?), (?)) AND f = ?", 0, 1, 2, 5); ++ + assertRows(execute("SELECT * FROM %s WHERE a = ? AND b = ? AND (c) IN ((?), (?)) AND f = ?", 0, 0, 1, 2, 5), + row(0, 0, 1, 1, 1, 5), + row(0, 0, 2, 0, 0, 5)); + assertRows(execute("SELECT * FROM %s WHERE a = ? AND (c) IN ((?), (?)) AND f = ? ALLOW FILTERING", 0, 1, 2, 5), row(0, 0, 1, 1, 1, 5), row(0, 0, 2, 0, 0, 5)); + assertRows(execute("SELECT * FROM %s WHERE a = ? AND b = ? AND (c, d) IN ((?, ?)) AND f = ?", 0, 0, 1, 0, 3), + row(0, 0, 1, 0, 0, 3)); - + assertInvalidMessage("Cannot execute this query as it might involve data filtering", + "SELECT * FROM %s WHERE a = ? AND (c, d) IN ((?, ?)) AND f = ?", 0, 1, 0, 3); assertRows(execute("SELECT * FROM %s WHERE a = ? AND (c, d) IN ((?, ?)) AND f = ? ALLOW FILTERING", 0, 1, 0, 3), row(0, 0, 1, 0, 0, 3)); + assertInvalidMessage("Cannot execute this query as it might involve data filtering", + "SELECT * FROM %s WHERE a = ? AND (c) >= (?) AND f = ?", 0, 1, 5); ++ + assertRows(execute("SELECT * FROM %s WHERE a = ? AND b = ? AND (c) >= (?) AND f = ?", 0, 0, 1, 5), + row(0, 0, 1, 1, 1, 5), + row(0, 0, 2, 0, 0, 5)); + assertRows(execute("SELECT * FROM %s WHERE a = ? AND (c) >= (?) AND f = ? ALLOW FILTERING", 0, 1, 5), row(0, 0, 1, 1, 1, 5), row(0, 0, 2, 0, 0, 5)); + assertRows(execute("SELECT * FROM %s WHERE a = ? AND b = ? AND (c, d) >= (?, ?) AND f = ?", 0, 0, 1, 1, 5), + row(0, 0, 1, 1, 1, 5), + row(0, 0, 2, 0, 0, 5)); - + assertInvalidMessage("Cannot execute this query as it might involve data filtering", + "SELECT * FROM %s WHERE a = ? AND (c, d) >= (?, ?) AND f = ?", 0, 1, 1, 5); assertRows(execute("SELECT * FROM %s WHERE a = ? AND (c, d) >= (?, ?) AND f = ? ALLOW FILTERING", 0, 1, 1, 5), row(0, 0, 1, 1, 1, 5), row(0, 0, 2, 0, 0, 5)); http://git-wip-us.apache.org/repos/asf/cassandra/blob/2a4ab871/test/unit/org/apache/cassandra/cql3/validation/operations/SelectSingleColumnRelationTest.java ---------------------------------------------------------------------- diff --cc test/unit/org/apache/cassandra/cql3/validation/operations/SelectSingleColumnRelationTest.java index fd43a51,05bb88b..57b8a86 --- a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectSingleColumnRelationTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectSingleColumnRelationTest.java @@@ -471,85 -93,24 +471,93 @@@ public class SelectSingleColumnRelation row(0, 0, 1, 1, 0, 4), row(0, 0, 1, 1, 1, 5)); - assertInvalidMessage("Partition key part b must be restricted since preceding part is", + assertInvalidMessage("Partition key parts: b must be restricted as other parts are", + "SELECT * FROM %s WHERE a = ? AND c IN (?) AND d IN (?) ALLOW FILTERING", 0, 1, 1); + + assertInvalidMessage("Partition key parts: b must be restricted as other parts are", + "SELECT * FROM %s WHERE a = ? AND (c, d) >= (?, ?) ALLOW FILTERING", 0, 1, 1); + + assertInvalidMessage("Cannot execute this query as it might involve data filtering", + "SELECT * FROM %s WHERE a = ? AND c IN (?) AND f = ?", 0, 1, 5); + assertRows(execute("SELECT * FROM %s WHERE a = ? AND c IN (?) AND f = ? ALLOW FILTERING", 0, 1, 5), + row(0, 0, 1, 1, 1, 5)); + + assertInvalidMessage("Cannot execute this query as it might involve data filtering", + "SELECT * FROM %s WHERE a = ? AND c IN (?, ?) AND f = ?", 0, 1, 2, 5); + assertRows(execute("SELECT * FROM %s WHERE a = ? AND c IN (?, ?) AND f = ? ALLOW FILTERING", 0, 1, 2, 5), + row(0, 0, 1, 1, 1, 5), + row(0, 0, 2, 0, 0, 5)); + + assertInvalidMessage("Cannot execute this query as it might involve data filtering", + "SELECT * FROM %s WHERE a = ? AND c IN (?) AND d IN (?) AND f = ?", 0, 1, 0, 3); + assertRows(execute("SELECT * FROM %s WHERE a = ? AND c IN (?) AND d IN (?) AND f = ? ALLOW FILTERING", 0, 1, 0, 3), + row(0, 0, 1, 0, 0, 3)); + + assertInvalidMessage("Partition key parts: b must be restricted as other parts are", "SELECT * FROM %s WHERE a = ? AND c >= ? ALLOW FILTERING", 0, 1); + assertInvalidMessage("Cannot execute this query as it might involve data filtering", + "SELECT * FROM %s WHERE a = ? AND c >= ? AND f = ?", 0, 1, 5); + assertRows(execute("SELECT * FROM %s WHERE a = ? AND b = ? AND c >= ? AND f = ?", 0, 0, 1, 5), + row(0, 0, 1, 1, 1, 5), + row(0, 0, 2, 0, 0, 5)); + assertRows(execute("SELECT * FROM %s WHERE a = ? AND c >= ? AND f = ? ALLOW FILTERING", 0, 1, 5), row(0, 0, 1, 1, 1, 5), row(0, 0, 2, 0, 0, 5)); + assertInvalidMessage("Cannot execute this query as it might involve data filtering", + "SELECT * FROM %s WHERE a = ? AND c = ? AND d >= ? AND f = ?", 0, 1, 1, 5); ++ + assertRows(execute("SELECT * FROM %s WHERE a = ? AND b = ? AND c = ? AND d >= ? AND f = ?", 0, 0, 1, 1, 5), + row(0, 0, 1, 1, 1, 5)); + assertRows(execute("SELECT * FROM %s WHERE a = ? AND c = ? AND d >= ? AND f = ? ALLOW FILTERING", 0, 1, 1, 5), row(0, 0, 1, 1, 1, 5)); + } - assertInvalidMessage("Cannot execute this query as it might involve data filtering and thus may have unpredictable performance. If you want to execute this query despite the performance unpredictability, use ALLOW FILTERING", - "SELECT * FROM %s WHERE a = ? AND d >= ? AND f = ?", 0, 1, 5); + @Test + public void testFunctionCallWithUnset() throws Throwable + { + createTable("CREATE TABLE %s (k int PRIMARY KEY, s text, i int)"); + + assertInvalidMessage("Invalid unset value for argument in call to function token", + "SELECT * FROM %s WHERE token(k) >= token(?)", unset()); + assertInvalidMessage("Invalid unset value for argument in call to function blobasint", + "SELECT * FROM %s WHERE k = blobAsInt(?)", unset()); + } + + @Test + public void testLimitWithUnset() throws Throwable + { + createTable("CREATE TABLE %s (k int PRIMARY KEY, i int)"); + execute("INSERT INTO %s (k, i) VALUES (1, 1)"); + execute("INSERT INTO %s (k, i) VALUES (2, 1)"); + assertRows(execute("SELECT k FROM %s LIMIT ?", unset()), // treat as 'unlimited' + row(1), + row(2) + ); + } + + @Test + public void testWithUnsetValues() throws Throwable + { + createTable("CREATE TABLE %s (k int, i int, j int, s text, PRIMARY KEY(k,i,j))"); + createIndex("CREATE INDEX s_index ON %s (s)"); + // partition key + assertInvalidMessage("Invalid unset value for column k", "SELECT * from %s WHERE k = ?", unset()); + assertInvalidMessage("Invalid unset value for column k", "SELECT * from %s WHERE k IN ?", unset()); + assertInvalidMessage("Invalid unset value for column k", "SELECT * from %s WHERE k IN(?)", unset()); + assertInvalidMessage("Invalid unset value for column k", "SELECT * from %s WHERE k IN(?,?)", 1, unset()); + // clustering column + assertInvalidMessage("Invalid unset value for column i", "SELECT * from %s WHERE k = 1 AND i = ?", unset()); + assertInvalidMessage("Invalid unset value for column i", "SELECT * from %s WHERE k = 1 AND i IN ?", unset()); + assertInvalidMessage("Invalid unset value for column i", "SELECT * from %s WHERE k = 1 AND i IN(?)", unset()); + assertInvalidMessage("Invalid unset value for column i", "SELECT * from %s WHERE k = 1 AND i IN(?,?)", 1, unset()); + assertInvalidMessage("Invalid unset value for column i", "SELECT * from %s WHERE i = ? ALLOW FILTERING", unset()); + // indexed column + assertInvalidMessage("Unsupported unset value for indexed column s", "SELECT * from %s WHERE s = ?", unset()); + // range + assertInvalidMessage("Invalid unset value for column i", "SELECT * from %s WHERE k = 1 AND i > ?", unset()); } }
