You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jm...@apache.org on 2015/06/24 18:15:00 UTC
[07/32] cassandra git commit: Migrate CQL tests from dtest to unit
tests
http://git-wip-us.apache.org/repos/asf/cassandra/blob/f797bfa4/test/unit/org/apache/cassandra/cql3/MultiColumnRelationTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/MultiColumnRelationTest.java b/test/unit/org/apache/cassandra/cql3/MultiColumnRelationTest.java
deleted file mode 100644
index a4ee5d7..0000000
--- a/test/unit/org/apache/cassandra/cql3/MultiColumnRelationTest.java
+++ /dev/null
@@ -1,808 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.cql3;
-
-import org.junit.Test;
-
-public class MultiColumnRelationTest extends CQLTester
-{
- @Test
- public void testSingleClusteringInvalidQueries() throws Throwable
- {
- for (String compactOption : new String[]{"", " WITH COMPACT STORAGE"})
- {
- createTable("CREATE TABLE %s (a int, b int, c int, PRIMARY KEY (a, b))" + compactOption);
-
- assertInvalidSyntax("SELECT * FROM %s WHERE () = (?, ?)", 1, 2);
- assertInvalidMessage("Column \"b\" cannot be restricted by an equality relation and an inequality relation",
- "SELECT * FROM %s WHERE a = 0 AND (b) = (?) AND (b) > (?)", 0, 0);
- assertInvalidMessage("More than one restriction was found for the start bound on b",
- "SELECT * FROM %s WHERE a = 0 AND (b) > (?) AND (b) > (?)", 0, 1);
- assertInvalidMessage("Multi-column relations can only be applied to clustering columns: a",
- "SELECT * FROM %s WHERE (a, b) = (?, ?)", 0, 0);
- }
- }
-
- @Test
- public void testMultiClusteringInvalidQueries() throws Throwable
- {
- for (String compactOption : new String[]{"", " WITH COMPACT STORAGE"})
- {
- createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b, c, d))" + compactOption);
-
- assertInvalidSyntax("SELECT * FROM %s WHERE a = 0 AND (b, c) > ()");
- assertInvalidMessage("Expected 2 elements in value tuple, but got 3: (?, ?, ?)",
- "SELECT * FROM %s WHERE a = 0 AND (b, c) > (?, ?, ?)", 1, 2, 3);
- assertInvalidMessage("Invalid null value in condition for column c",
- "SELECT * FROM %s WHERE a = 0 AND (b, c) > (?, ?)", 1, null);
-
- // Wrong order of columns
- assertInvalidMessage("Clustering columns must appear in the PRIMARY KEY order in multi-column relations: (d, c, b) = (?, ?, ?)",
- "SELECT * FROM %s WHERE a = 0 AND (d, c, b) = (?, ?, ?)", 0, 0, 0);
- assertInvalidMessage("Clustering columns must appear in the PRIMARY KEY order in multi-column relations: (d, c, b) > (?, ?, ?)",
- "SELECT * FROM %s WHERE a = 0 AND (d, c, b) > (?, ?, ?)", 0, 0, 0);
-
- // Wrong number of values
- assertInvalidMessage("Expected 3 elements in value tuple, but got 2: (?, ?)",
- "SELECT * FROM %s WHERE a=0 AND (b, c, d) IN ((?, ?))", 0, 1);
- assertInvalidMessage("Expected 3 elements in value tuple, but got 5: (?, ?, ?, ?, ?)",
- "SELECT * FROM %s WHERE a=0 AND (b, c, d) IN ((?, ?, ?, ?, ?))", 0, 1, 2, 3, 4);
-
- // Missing first clustering column
- assertInvalidMessage("PRIMARY KEY column \"c\" cannot be restricted (preceding column \"b\" is not restricted)",
- "SELECT * FROM %s WHERE a = 0 AND (c, d) = (?, ?)", 0, 0);
- assertInvalidMessage("PRIMARY KEY column \"c\" cannot be restricted (preceding column \"b\" is not restricted)",
- "SELECT * FROM %s WHERE a = 0 AND (c, d) > (?, ?)", 0, 0);
-
- // Nulls
- assertInvalidMessage("Invalid null value in condition for column d",
- "SELECT * FROM %s WHERE a = 0 AND (b, c, d) IN ((?, ?, ?))", 1, 2, null);
-
- // Wrong type for 'd'
- assertInvalidMessage("Expected 4 or 0 byte int (6)",
- "SELECT * FROM %s WHERE a = 0 AND (b, c, d) = (?, ?, ?)", 1, 2, "foobar");
-
- assertInvalidMessage("Invalid tuple type literal for b of type int",
- "SELECT * FROM %s WHERE a = 0 AND b = (?, ?, ?)", 1, 2, 3);
-
- // Mix single and tuple inequalities
- assertInvalidMessage("Column \"b\" cannot be restricted by both a tuple notation inequality and a single column inequality (b < ?)",
- "SELECT * FROM %s WHERE a = 0 AND (b, c, d) > (?, ?, ?) AND b < ?", 0, 1, 0, 1);
- assertInvalidMessage("Column \"c\" cannot be restricted by both a tuple notation inequality and a single column inequality (c < ?)",
- "SELECT * FROM %s WHERE a = 0 AND (b, c, d) > (?, ?, ?) AND c < ?", 0, 1, 0, 1);
- assertInvalidMessage("Column \"b\" cannot have both tuple-notation inequalities and single-column inequalities: (b, c, d) < (?, ?, ?)",
- "SELECT * FROM %s WHERE a = 0 AND b > ? AND (b, c, d) < (?, ?, ?)", 1, 1, 1, 0);
- assertInvalidMessage("Column \"c\" cannot have both tuple-notation inequalities and single-column inequalities: (b, c, d) < (?, ?, ?)",
- "SELECT * FROM %s WHERE a = 0 AND c > ? AND (b, c, d) < (?, ?, ?)", 1, 1, 1, 0);
-
- assertInvalidMessage("Multi-column relations can only be applied to clustering columns: a",
- "SELECT * FROM %s WHERE (a, b, c, d) IN ((?, ?, ?, ?))", 0, 1, 2, 3);
- assertInvalidMessage("PRIMARY KEY column \"c\" cannot be restricted (preceding column \"b\" is not restricted)",
- "SELECT * FROM %s WHERE (c, d) IN ((?, ?))", 0, 1);
- assertInvalidMessage("PRIMARY KEY column \"c\" cannot be restricted (preceding column \"b\" is restricted by a non-EQ relation)",
- "SELECT * FROM %s WHERE a = ? AND b > ? AND (c, d) IN ((?, ?))", 0, 0, 0, 0);
-
- assertInvalidMessage("PRIMARY KEY column \"c\" cannot be restricted (preceding column \"b\" is restricted by a non-EQ relation)",
- "SELECT * FROM %s WHERE a = ? AND b > ? AND (c, d) > (?, ?)", 0, 0, 0, 0);
- assertInvalidMessage("PRIMARY KEY column \"c\" cannot be restricted (preceding column \"b\" is restricted by a non-EQ relation)",
- "SELECT * FROM %s WHERE a = ? AND (c, d) > (?, ?) AND b > ? ", 0, 0, 0, 0);
- assertInvalidMessage("Column \"c\" cannot be restricted by two tuple-notation inequalities not starting with the same column: (c) < (?)",
- "SELECT * FROM %s WHERE a = ? AND (b, c) > (?, ?) AND (b) < (?) AND (c) < (?)", 0, 0, 0, 0, 0);
- assertInvalidMessage("Column \"c\" cannot be restricted by two tuple-notation inequalities not starting with the same column: (b, c) > (?, ?)",
- "SELECT * FROM %s WHERE a = ? AND (c) < (?) AND (b, c) > (?, ?) AND (b) < (?)", 0, 0, 0, 0, 0);
- assertInvalidMessage("Column \"c\" cannot be restricted by two tuple-notation inequalities not starting with the same column: (b, c) > (?, ?)",
- "SELECT * FROM %s WHERE a = ? AND (b) < (?) AND (c) < (?) AND (b, c) > (?, ?)", 0, 0, 0, 0, 0);
-
- assertInvalidMessage("Column \"c\" cannot be restricted by two tuple-notation inequalities not starting with the same column: (c) < (?)",
- "SELECT * FROM %s WHERE a = ? AND (b, c) > (?, ?) AND (c) < (?)", 0, 0, 0, 0);
-
- assertInvalidMessage("PRIMARY KEY column \"d\" cannot be restricted (preceding column \"c\" is restricted by an IN tuple notation)",
- "SELECT * FROM %s WHERE a = ? AND (b, c) in ((?, ?), (?, ?)) AND d > ?", 0, 0, 0, 0, 0, 0);
- }
- }
-
- @Test
- public void testMultiAndSingleColumnRelationMix() throws Throwable
- {
- for (String compactOption : new String[]{"", " WITH COMPACT STORAGE"})
- {
- createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b, c, d))" + compactOption);
-
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 0, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 1);
-
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 0, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 1);
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and b = ? and (c, d) = (?, ?)", 0, 1, 0, 0),
- row(0, 1, 0, 0));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and b = ? and (c) IN ((?))", 0, 1, 0),
- row(0, 1, 0, 0));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and b = ? and (c) IN ((?), (?))", 0, 1, 0, 1),
- row(0, 1, 0, 0),
- row(0, 1, 1, 0),
- row(0, 1, 1, 1));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and b = ? and (c, d) IN ((?, ?))", 0, 1, 0, 0),
- row(0, 1, 0, 0));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and b = ? and (c, d) IN ((?, ?), (?, ?))", 0, 1, 0, 0, 1, 1),
- row(0, 1, 0, 0),
- row(0, 1, 1, 1));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and b = ? and (c, d) > (?, ?)", 0, 1, 0, 0),
- row(0, 1, 1, 0),
- row(0, 1, 1, 1));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and b = ? and (c, d) > (?, ?) and (c) <= (?) ", 0, 1, 0, 0, 1),
- row(0, 1, 1, 0),
- row(0, 1, 1, 1));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and b = ? and (c, d) >= (?, ?) and (c, d) < (?, ?)", 0, 1, 0, 0, 1, 1),
- row(0, 1, 0, 0),
- row(0, 1, 1, 0));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and (b, c) = (?, ?) and d = ?", 0, 0, 1, 0),
- row(0, 0, 1, 0));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and b = ? and (c) = (?) and d = ?", 0, 0, 1, 0),
- row(0, 0, 1, 0));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and (b, c) = (?, ?) and d IN (?, ?)", 0, 0, 1, 0, 2),
- row(0, 0, 1, 0));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and b = ? and (c) = (?) and d IN (?, ?)", 0, 0, 1, 0, 2),
- row(0, 0, 1, 0));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and (b, c) = (?, ?) and d >= ?", 0, 0, 1, 0),
- row(0, 0, 1, 0),
- row(0, 0, 1, 1));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and d < 1 and (b, c) = (?, ?) and d >= ?", 0, 0, 1, 0),
- row(0, 0, 1, 0));
- }
- }
-
- @Test
- public void testMultipleMultiColumnRelation() throws Throwable
- {
- for (String compactOption : new String[]{"", " WITH COMPACT STORAGE"})
- {
- createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b, c, d))" + compactOption);
-
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 0, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 1);
-
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 0, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 1);
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and (b) = (?) and (c, d) = (?, ?)", 0, 1, 0, 0),
- row(0, 1, 0, 0));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and (b) = (?) and (c) = (?) and (d) = (?)", 0, 1, 0, 0),
- row(0, 1, 0, 0));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and (b) = (?) and (c) IN ((?))", 0, 1, 0),
- row(0, 1, 0, 0));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and (b) = (?) and (c) IN ((?), (?))", 0, 1, 0, 1),
- row(0, 1, 0, 0),
- row(0, 1, 1, 0),
- row(0, 1, 1, 1));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and (b) = (?) and (c, d) IN ((?, ?))", 0, 1, 0, 0),
- row(0, 1, 0, 0));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and (b) = (?) and (c, d) IN ((?, ?), (?, ?))", 0, 1, 0, 0, 1, 1),
- row(0, 1, 0, 0),
- row(0, 1, 1, 1));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and (b) = (?) and (c, d) > (?, ?)", 0, 1, 0, 0),
- row(0, 1, 1, 0),
- row(0, 1, 1, 1));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and (b) = (?) and (c, d) > (?, ?) and (c) <= (?) ", 0, 1, 0, 0, 1),
- row(0, 1, 1, 0),
- row(0, 1, 1, 1));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and (b) = (?) and (c, d) >= (?, ?) and (c, d) < (?, ?)", 0, 1, 0, 0, 1, 1),
- row(0, 1, 0, 0),
- row(0, 1, 1, 0));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and (b, c) = (?, ?) and (d) = (?)", 0, 0, 1, 0),
- row(0, 0, 1, 0));
- }
- }
-
- @Test
- public void testSinglePartitionInvalidQueries() throws Throwable
- {
- for (String compactOption : new String[]{"", " WITH COMPACT STORAGE"})
- {
- createTable("CREATE TABLE %s (a int PRIMARY KEY, b int)" + compactOption);
-
- assertInvalid("SELECT * FROM %s WHERE (a) > (?)", 0);
- assertInvalid("SELECT * FROM %s WHERE (a) = (?)", 0);
- assertInvalid("SELECT * FROM %s WHERE (b) = (?)", 0);
- }
- }
-
- @Test
- public void testSingleClustering() throws Throwable
- {
- for (String compactOption : new String[]{"", " WITH COMPACT STORAGE"})
- {
- createTable("CREATE TABLE %s (a int, b int, c int, PRIMARY KEY (a, b))" + compactOption);
-
- execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", 0, 0, 0);
- execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", 0, 1, 0);
- execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", 0, 2, 0);
-
- // Equalities
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) = (?)", 0, 1),
- row(0, 1, 0)
- );
-
- // Same but check the whole tuple can be prepared
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) = ?", 0, tuple(1)),
- row(0, 1, 0)
- );
-
- assertEmpty(execute("SELECT * FROM %s WHERE a = ? AND (b) = (?)", 0, 3));
-
- // Inequalities
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) > (?)", 0, 0),
- row(0, 1, 0),
- row(0, 2, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) >= (?)", 0, 1),
- row(0, 1, 0),
- row(0, 2, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) < (?)", 0, 2),
- row(0, 0, 0),
- row(0, 1, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) <= (?)", 0, 1),
- row(0, 0, 0),
- row(0, 1, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) > (?) AND (b) < (?)", 0, 0, 2),
- row(0, 1, 0)
- );
- }
- }
-
- @Test
- public void testNonEqualsRelation() throws Throwable
- {
- for (String compactOption : new String[]{"", " WITH COMPACT STORAGE"})
- {
- createTable("CREATE TABLE %s (a int PRIMARY KEY, b int)" + compactOption);
- assertInvalid("SELECT * FROM %s WHERE a = 0 AND (b) != (0)");
- }
- }
-
- @Test
- public void testMultipleClustering() throws Throwable
- {
- for (String compactOption : new String[]{"", " WITH COMPACT STORAGE"})
- {
- createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b, c, d))" + compactOption);
-
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 0, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 1);
-
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 0, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 1);
-
- // Empty query
- assertEmpty(execute("SELECT * FROM %s WHERE a = 0 AND (b, c, d) IN ()"));
-
- // Equalities
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) = (?)", 0, 1),
- row(0, 1, 0, 0),
- row(0, 1, 1, 0),
- row(0, 1, 1, 1)
- );
-
- // Same with whole tuple prepared
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) = ?", 0, tuple(1)),
- row(0, 1, 0, 0),
- row(0, 1, 1, 0),
- row(0, 1, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c) = (?, ?)", 0, 1, 1),
- row(0, 1, 1, 0),
- row(0, 1, 1, 1)
- );
-
- // Same with whole tuple prepared
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c) = ?", 0, tuple(1, 1)),
- row(0, 1, 1, 0),
- row(0, 1, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) = (?, ?, ?)", 0, 1, 1, 1),
- row(0, 1, 1, 1)
- );
-
- // Same with whole tuple prepared
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) = ?", 0, tuple(1, 1, 1)),
- row(0, 1, 1, 1)
- );
-
- // Inequalities
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) > (?)", 0, 0),
- row(0, 1, 0, 0),
- row(0, 1, 1, 0),
- row(0, 1, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) >= (?)", 0, 0),
- row(0, 0, 0, 0),
- row(0, 0, 1, 0),
- row(0, 0, 1, 1),
- row(0, 1, 0, 0),
- row(0, 1, 1, 0),
- row(0, 1, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c) > (?, ?)", 0, 1, 0),
- row(0, 1, 1, 0),
- row(0, 1, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c) >= (?, ?)", 0, 1, 0),
- row(0, 1, 0, 0),
- row(0, 1, 1, 0),
- row(0, 1, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) > (?, ?, ?)", 0, 1, 1, 0),
- row(0, 1, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) >= (?, ?, ?)", 0, 1, 1, 0),
- row(0, 1, 1, 0),
- row(0, 1, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) < (?)", 0, 1),
- row(0, 0, 0, 0),
- row(0, 0, 1, 0),
- row(0, 0, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) <= (?)", 0, 1),
- row(0, 0, 0, 0),
- row(0, 0, 1, 0),
- row(0, 0, 1, 1),
- row(0, 1, 0, 0),
- row(0, 1, 1, 0),
- row(0, 1, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c) < (?, ?)", 0, 0, 1),
- row(0, 0, 0, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c) <= (?, ?)", 0, 0, 1),
- row(0, 0, 0, 0),
- row(0, 0, 1, 0),
- row(0, 0, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) < (?, ?, ?)", 0, 0, 1, 1),
- row(0, 0, 0, 0),
- row(0, 0, 1, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) <= (?, ?, ?)", 0, 0, 1, 1),
- row(0, 0, 0, 0),
- row(0, 0, 1, 0),
- row(0, 0, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) > (?, ?, ?) AND (b) < (?)", 0, 0, 1, 0, 1),
- row(0, 0, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) > (?, ?, ?) AND (b, c) < (?, ?)", 0, 0, 1, 1, 1, 1),
- row(0, 1, 0, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) > (?, ?, ?) AND (b, c, d) < (?, ?, ?)", 0, 0, 1, 1, 1, 1, 0),
- row(0, 1, 0, 0)
- );
-
- // Same with whole tuple prepared
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) > ? AND (b, c, d) < ?", 0, tuple(0, 1, 1), tuple(1, 1, 0)),
- row(0, 1, 0, 0)
- );
-
- // reversed
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) > (?) ORDER BY b DESC, c DESC, d DESC", 0, 0),
- row(0, 1, 1, 1),
- row(0, 1, 1, 0),
- row(0, 1, 0, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) >= (?) ORDER BY b DESC, c DESC, d DESC", 0, 0),
- row(0, 1, 1, 1),
- row(0, 1, 1, 0),
- row(0, 1, 0, 0),
- row(0, 0, 1, 1),
- row(0, 0, 1, 0),
- row(0, 0, 0, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c) > (?, ?) ORDER BY b DESC, c DESC, d DESC", 0, 1, 0),
- row(0, 1, 1, 1),
- row(0, 1, 1, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c) >= (?, ?) ORDER BY b DESC, c DESC, d DESC", 0, 1, 0),
- row(0, 1, 1, 1),
- row(0, 1, 1, 0),
- row(0, 1, 0, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) > (?, ?, ?) ORDER BY b DESC, c DESC, d DESC", 0, 1, 1, 0),
- row(0, 1, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) >= (?, ?, ?) ORDER BY b DESC, c DESC, d DESC", 0, 1, 1, 0),
- row(0, 1, 1, 1),
- row(0, 1, 1, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) < (?) ORDER BY b DESC, c DESC, d DESC", 0, 1),
- row(0, 0, 1, 1),
- row(0, 0, 1, 0),
- row(0, 0, 0, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) <= (?) ORDER BY b DESC, c DESC, d DESC", 0, 1),
- row(0, 1, 1, 1),
- row(0, 1, 1, 0),
- row(0, 1, 0, 0),
- row(0, 0, 1, 1),
- row(0, 0, 1, 0),
- row(0, 0, 0, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c) < (?, ?) ORDER BY b DESC, c DESC, d DESC", 0, 0, 1),
- row(0, 0, 0, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c) <= (?, ?) ORDER BY b DESC, c DESC, d DESC", 0, 0, 1),
- row(0, 0, 1, 1),
- row(0, 0, 1, 0),
- row(0, 0, 0, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) < (?, ?, ?) ORDER BY b DESC, c DESC, d DESC", 0, 0, 1, 1),
- row(0, 0, 1, 0),
- row(0, 0, 0, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) <= (?, ?, ?) ORDER BY b DESC, c DESC, d DESC", 0, 0, 1, 1),
- row(0, 0, 1, 1),
- row(0, 0, 1, 0),
- row(0, 0, 0, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) > (?, ?, ?) AND (b) < (?) ORDER BY b DESC, c DESC, d DESC", 0, 0, 1, 0, 1),
- row(0, 0, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) > (?, ?, ?) AND (b, c) < (?, ?) ORDER BY b DESC, c DESC, d DESC", 0, 0, 1, 1, 1, 1),
- row(0, 1, 0, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) > (?, ?, ?) AND (b, c, d) < (?, ?, ?) ORDER BY b DESC, c DESC, d DESC", 0, 0, 1, 1, 1, 1, 0),
- row(0, 1, 0, 0)
- );
-
- // IN
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) IN ((?, ?, ?), (?, ?, ?))", 0, 0, 1, 0, 0, 1, 1),
- row(0, 0, 1, 0),
- row(0, 0, 1, 1)
- );
-
- // same query but with whole tuple prepared
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) IN (?, ?)", 0, tuple(0, 1, 0), tuple(0, 1, 1)),
- row(0, 0, 1, 0),
- row(0, 0, 1, 1)
- );
-
- // same query but with whole IN list prepared
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) IN ?", 0, list(tuple(0, 1, 0), tuple(0, 1, 1))),
- row(0, 0, 1, 0),
- row(0, 0, 1, 1)
- );
-
- // same query, but reversed order for the IN values
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) IN (?, ?)", 0, tuple(0, 1, 1), tuple(0, 1, 0)),
- row(0, 0, 1, 0),
- row(0, 0, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and (b, c) IN ((?, ?))", 0, 0, 1),
- row(0, 0, 1, 0),
- row(0, 0, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? and (b) IN ((?))", 0, 0),
- row(0, 0, 0, 0),
- row(0, 0, 1, 0),
- row(0, 0, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c) IN ((?, ?)) ORDER BY b DESC, c DESC, d DESC", 0, 0, 1),
- row(0, 0, 1, 1),
- row(0, 0, 1, 0)
- );
-
- // IN on both partition key and clustering key
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 0, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 1, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 1, 1);
-
- assertRows(execute("SELECT * FROM %s WHERE a IN (?, ?) AND (b, c, d) IN (?, ?)", 0, 1, tuple(0, 1, 0), tuple(0, 1, 1)),
- row(0, 0, 1, 0),
- row(0, 0, 1, 1),
- row(1, 0, 1, 0),
- row(1, 0, 1, 1)
- );
-
- // same but with whole IN lists prepared
- assertRows(execute("SELECT * FROM %s WHERE a IN ? AND (b, c, d) IN ?", list(0, 1), list(tuple(0, 1, 0), tuple(0, 1, 1))),
- row(0, 0, 1, 0),
- row(0, 0, 1, 1),
- row(1, 0, 1, 0),
- row(1, 0, 1, 1)
- );
-
- // same query, but reversed order for the IN values
- assertRows(execute("SELECT * FROM %s WHERE a IN (?, ?) AND (b, c, d) IN (?, ?)", 1, 0, tuple(0, 1, 1), tuple(0, 1, 0)),
- row(1, 0, 1, 0),
- row(1, 0, 1, 1),
- row(0, 0, 1, 0),
- row(0, 0, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a IN (?, ?) and (b, c) IN ((?, ?))", 0, 1, 0, 1),
- row(0, 0, 1, 0),
- row(0, 0, 1, 1),
- row(1, 0, 1, 0),
- row(1, 0, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a IN (?, ?) and (b) IN ((?))", 0, 1, 0),
- row(0, 0, 0, 0),
- row(0, 0, 1, 0),
- row(0, 0, 1, 1),
- row(1, 0, 0, 0),
- row(1, 0, 1, 0),
- row(1, 0, 1, 1)
- );
- }
- }
-
- @Test
- public void testMultipleClusteringReversedComponents() throws Throwable
- {
- for (String compactOption : new String[]{"", " COMPACT STORAGE AND"})
- {
- createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b, c, d)) WITH" + compactOption + " CLUSTERING ORDER BY (b DESC, c ASC, d DESC)");
-
- // b and d are reversed in the clustering order
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 0, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 1);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 0);
-
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 0, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 1);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 0);
-
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) > (?)", 0, 0),
- row(0, 1, 0, 0),
- row(0, 1, 1, 1),
- row(0, 1, 1, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) >= (?)", 0, 0),
- row(0, 1, 0, 0),
- row(0, 1, 1, 1),
- row(0, 1, 1, 0),
- row(0, 0, 0, 0),
- row(0, 0, 1, 1),
- row(0, 0, 1, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) < (?)", 0, 1),
- row(0, 0, 0, 0),
- row(0, 0, 1, 1),
- row(0, 0, 1, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) <= (?)", 0, 1),
- row(0, 1, 0, 0),
- row(0, 1, 1, 1),
- row(0, 1, 1, 0),
- row(0, 0, 0, 0),
- row(0, 0, 1, 1),
- row(0, 0, 1, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a=? AND (b, c, d) IN ((?, ?, ?), (?, ?, ?))", 0, 1, 1, 1, 0, 1, 1),
- row(0, 1, 1, 1),
- row(0, 0, 1, 1)
- );
-
- // same query, but reversed order for the IN values
- assertRows(execute("SELECT * FROM %s WHERE a=? AND (b, c, d) IN ((?, ?, ?), (?, ?, ?))", 0, 0, 1, 1, 1, 1, 1),
- row(0, 1, 1, 1),
- row(0, 0, 1, 1)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c, d) IN (?, ?, ?, ?, ?, ?)",
- 0, tuple(1, 0, 0), tuple(1, 1, 1), tuple(1, 1, 0), tuple(0, 0, 0), tuple(0, 1, 1), tuple(0, 1, 0)),
- row(0, 1, 0, 0),
- row(0, 1, 1, 1),
- row(0, 1, 1, 0),
- row(0, 0, 0, 0),
- row(0, 0, 1, 1),
- row(0, 0, 1, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c) IN (?)", 0, tuple(0, 1)),
- row(0, 0, 1, 1),
- row(0, 0, 1, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b, c) IN (?)", 0, tuple(0, 0)),
- row(0, 0, 0, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (b) IN ((?))", 0, 0),
- row(0, 0, 0, 0),
- row(0, 0, 1, 1),
- row(0, 0, 1, 0)
- );
-
- // preserve pre-6875 behavior (even though the query result is technically incorrect)
- assertEmpty(execute("SELECT * FROM %s WHERE a = ? AND (b, c) > (?, ?)", 0, 1, 0));
- }
- }
-
- @Test
- public void testMultipleClusteringWithIndex() throws Throwable
- {
- createTable("CREATE TABLE %s (a int, b int, c int, d int, e int, PRIMARY KEY (a, b, c, d))");
- createIndex("CREATE INDEX ON %s (b)");
- createIndex("CREATE INDEX ON %s (e)");
- 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, 0, 1, 0, 1);
- execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 0, 1, 1, 2);
- 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, 1, 0, 1);
- execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 1, 1, 1, 2);
- execute("INSERT INTO %s (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)", 0, 2, 0, 0, 0);
- assertRows(execute("SELECT * FROM %s WHERE (b) = (?)", 1),
- row(0, 1, 0, 0, 0),
- 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 (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),
- row(0, 1, 1, 1, 2));
-
- assertRows(execute("SELECT * FROM %s WHERE (b) IN ((?), (?)) AND e = ?", 0, 1, 2),
- row(0, 0, 1, 1, 2),
- row(0, 1, 1, 1, 2));
-
- assertRows(execute("SELECT * FROM %s WHERE (b, c) IN ((?, ?)) AND e = ?", 0, 1, 2),
- row(0, 0, 1, 1, 2));
-
- assertRows(execute("SELECT * FROM %s WHERE (b, c) IN ((?, ?), (?, ?)) AND e = ?", 0, 1, 1, 1, 2),
- row(0, 0, 1, 1, 2),
- row(0, 1, 1, 1, 2));
-
- assertRows(execute("SELECT * FROM %s WHERE (b) >= (?) AND e = ?", 1, 2),
- row(0, 1, 1, 1, 2));
-
- assertRows(execute("SELECT * FROM %s WHERE (b, c) >= (?, ?) AND e = ?", 1, 1, 2),
- row(0, 1, 1, 1, 2));
- }
-
- @Test
- public void testMultiplePartitionKeyAndMultiClusteringWithIndex() throws Throwable
- {
- createTable("CREATE TABLE %s (a int, b int, c int, d int, e int, f int, PRIMARY KEY ((a, b), c, d, e))");
- createIndex("CREATE INDEX ON %s (c)");
- createIndex("CREATE INDEX ON %s (f)");
-
- execute("INSERT INTO %s (a, b, c, d, e, f) VALUES (?, ?, ?, ?, ?, ?)", 0, 0, 0, 0, 0, 0);
- execute("INSERT INTO %s (a, b, c, d, e, f) VALUES (?, ?, ?, ?, ?, ?)", 0, 0, 0, 1, 0, 1);
- execute("INSERT INTO %s (a, b, c, d, e, f) VALUES (?, ?, ?, ?, ?, ?)", 0, 0, 0, 1, 1, 2);
-
- execute("INSERT INTO %s (a, b, c, d, e, f) VALUES (?, ?, ?, ?, ?, ?)", 0, 0, 1, 0, 0, 3);
- execute("INSERT INTO %s (a, b, c, d, e, f) VALUES (?, ?, ?, ?, ?, ?)", 0, 0, 1, 1, 0, 4);
- execute("INSERT INTO %s (a, b, c, d, e, f) VALUES (?, ?, ?, ?, ?, ?)", 0, 0, 1, 1, 1, 5);
-
- execute("INSERT INTO %s (a, b, c, d, e, f) VALUES (?, ?, ?, ?, ?, ?)", 0, 0, 2, 0, 0, 5);
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (c) = (?) ALLOW FILTERING", 0, 1),
- row(0, 0, 1, 0, 0, 3),
- row(0, 0, 1, 1, 0, 4),
- row(0, 0, 1, 1, 1, 5));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (c, d) = (?, ?) ALLOW FILTERING", 0, 1, 1),
- 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",
- "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",
- "SELECT * FROM %s WHERE a = ? AND (c, d) >= (?, ?) ALLOW FILTERING", 0, 1, 1);
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND (c) IN ((?)) AND f = ? ALLOW FILTERING", 0, 1, 5),
- row(0, 0, 1, 1, 1, 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 (c, d) IN ((?, ?)) AND f = ? ALLOW FILTERING", 0, 1, 0, 3),
- row(0, 0, 1, 0, 0, 3));
-
- 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 (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/f797bfa4/test/unit/org/apache/cassandra/cql3/RangeDeletionTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/RangeDeletionTest.java b/test/unit/org/apache/cassandra/cql3/RangeDeletionTest.java
deleted file mode 100644
index b31d0c2..0000000
--- a/test/unit/org/apache/cassandra/cql3/RangeDeletionTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.cql3;
-
-import org.junit.Test;
-
-public class RangeDeletionTest extends CQLTester
-{
- @Test
- public void testCassandra8558() throws Throwable
- {
- createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b, c))");
-
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 1, 1);
- flush();
- execute("DELETE FROM %s WHERE a=? AND b=?", 1, 1);
- flush();
- assertEmpty(execute("SELECT * FROM %s WHERE a=? AND b=? AND c=?", 1, 1, 1));
- }
-}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/f797bfa4/test/unit/org/apache/cassandra/cql3/SSTableMetadataTrackingTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/SSTableMetadataTrackingTest.java b/test/unit/org/apache/cassandra/cql3/SSTableMetadataTrackingTest.java
deleted file mode 100644
index 7c3965f..0000000
--- a/test/unit/org/apache/cassandra/cql3/SSTableMetadataTrackingTest.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.cql3;
-
-import org.junit.Test;
-
-import org.apache.cassandra.db.ColumnFamilyStore;
-import org.apache.cassandra.db.Keyspace;
-import org.apache.cassandra.io.sstable.metadata.StatsMetadata;
-import static org.junit.Assert.assertEquals;
-
-public class SSTableMetadataTrackingTest extends CQLTester
-{
- @Test
- public void baseCheck() throws Throwable
- {
- createTable("CREATE TABLE %s (a int, b int, c text, PRIMARY KEY (a, b))");
- ColumnFamilyStore cfs = Keyspace.open(keyspace()).getColumnFamilyStore(currentTable());
- execute("INSERT INTO %s (a,b,c) VALUES (1,1,'1') using timestamp 9999");
- cfs.forceBlockingFlush();
- StatsMetadata metadata = cfs.getSSTables().iterator().next().getSSTableMetadata();
- assertEquals(9999, metadata.minTimestamp);
- assertEquals(Integer.MAX_VALUE, metadata.maxLocalDeletionTime);
- cfs.forceMajorCompaction();
- metadata = cfs.getSSTables().iterator().next().getSSTableMetadata();
- assertEquals(9999, metadata.minTimestamp);
- assertEquals(Integer.MAX_VALUE, metadata.maxLocalDeletionTime);
- }
-
- @Test
- public void testMinMaxtimestampRange() throws Throwable
- {
- createTable("CREATE TABLE %s (a int, b int, c text, PRIMARY KEY (a, b))");
- ColumnFamilyStore cfs = Keyspace.open(keyspace()).getColumnFamilyStore(currentTable());
- execute("INSERT INTO %s (a,b,c) VALUES (1,1,'1') using timestamp 10000");
- execute("DELETE FROM %s USING TIMESTAMP 9999 WHERE a = 1 and b = 1");
- cfs.forceBlockingFlush();
- StatsMetadata metadata = cfs.getSSTables().iterator().next().getSSTableMetadata();
- assertEquals(9999, metadata.minTimestamp);
- assertEquals(10000, metadata.maxTimestamp);
- assertEquals(Integer.MAX_VALUE, metadata.maxLocalDeletionTime, 5);
- cfs.forceMajorCompaction();
- metadata = cfs.getSSTables().iterator().next().getSSTableMetadata();
- assertEquals(9999, metadata.minTimestamp);
- assertEquals(10000, metadata.maxTimestamp);
- assertEquals(Integer.MAX_VALUE, metadata.maxLocalDeletionTime, 5);
- }
-
- @Test
- public void testMinMaxtimestampRow() throws Throwable
- {
- createTable("CREATE TABLE %s (a int, b int, c text, PRIMARY KEY (a, b))");
- ColumnFamilyStore cfs = Keyspace.open(keyspace()).getColumnFamilyStore(currentTable());
- execute("INSERT INTO %s (a,b,c) VALUES (1,1,'1') using timestamp 10000");
- execute("DELETE FROM %s USING TIMESTAMP 9999 WHERE a = 1");
- cfs.forceBlockingFlush();
- StatsMetadata metadata = cfs.getSSTables().iterator().next().getSSTableMetadata();
- assertEquals(9999, metadata.minTimestamp);
- assertEquals(10000, metadata.maxTimestamp);
- assertEquals(Integer.MAX_VALUE, metadata.maxLocalDeletionTime, 5);
- cfs.forceMajorCompaction();
- metadata = cfs.getSSTables().iterator().next().getSSTableMetadata();
- assertEquals(9999, metadata.minTimestamp);
- assertEquals(10000, metadata.maxTimestamp);
- assertEquals(Integer.MAX_VALUE, metadata.maxLocalDeletionTime, 5);
- }
-
-
- @Test
- public void testTrackMetadata_rangeTombstone() throws Throwable
- {
- createTable("CREATE TABLE %s (a int, b int, c text, PRIMARY KEY (a, b)) WITH gc_grace_seconds = 10000");
- ColumnFamilyStore cfs = Keyspace.open(keyspace()).getColumnFamilyStore(currentTable());
- execute("DELETE FROM %s USING TIMESTAMP 9999 WHERE a = 1 and b = 1");
- cfs.forceBlockingFlush();
- assertEquals(1, cfs.getSSTables().size());
- StatsMetadata metadata = cfs.getSSTables().iterator().next().getSSTableMetadata();
- assertEquals(9999, metadata.minTimestamp);
- assertEquals(9999, metadata.maxTimestamp);
- assertEquals(System.currentTimeMillis()/1000, metadata.maxLocalDeletionTime, 5);
- cfs.forceMajorCompaction();
- StatsMetadata metadata2 = cfs.getSSTables().iterator().next().getSSTableMetadata();
- assertEquals(metadata.maxLocalDeletionTime, metadata2.maxLocalDeletionTime);
- assertEquals(metadata.minTimestamp, metadata2.minTimestamp);
- assertEquals(metadata.maxTimestamp, metadata2.maxTimestamp);
- }
-
- @Test
- public void testTrackMetadata_rowTombstone() throws Throwable
- {
- createTable("CREATE TABLE %s (a int, b int, c text, PRIMARY KEY (a, b))");
- ColumnFamilyStore cfs = Keyspace.open(keyspace()).getColumnFamilyStore(currentTable());
- execute("DELETE FROM %s USING TIMESTAMP 9999 WHERE a = 1");
-
- cfs.forceBlockingFlush();
- assertEquals(1, cfs.getSSTables().size());
- StatsMetadata metadata = cfs.getSSTables().iterator().next().getSSTableMetadata();
- assertEquals(9999, metadata.minTimestamp);
- assertEquals(9999, metadata.maxTimestamp);
- assertEquals(System.currentTimeMillis()/1000, metadata.maxLocalDeletionTime, 5);
- cfs.forceMajorCompaction();
- StatsMetadata metadata2 = cfs.getSSTables().iterator().next().getSSTableMetadata();
- assertEquals(metadata.maxLocalDeletionTime, metadata2.maxLocalDeletionTime);
- assertEquals(metadata.minTimestamp, metadata2.minTimestamp);
- assertEquals(metadata.maxTimestamp, metadata2.maxTimestamp);
- }
-
- @Test
- public void testTrackMetadata_rowMarker() throws Throwable
- {
- createTable("CREATE TABLE %s (a int, PRIMARY KEY (a))");
- ColumnFamilyStore cfs = Keyspace.open(keyspace()).getColumnFamilyStore(currentTable());
- execute("INSERT INTO %s (a) VALUES (1) USING TIMESTAMP 9999");
-
- cfs.forceBlockingFlush();
- assertEquals(1, cfs.getSSTables().size());
- StatsMetadata metadata = cfs.getSSTables().iterator().next().getSSTableMetadata();
- assertEquals(9999, metadata.minTimestamp);
- assertEquals(9999, metadata.maxTimestamp);
- assertEquals(Integer.MAX_VALUE, metadata.maxLocalDeletionTime);
- cfs.forceMajorCompaction();
- StatsMetadata metadata2 = cfs.getSSTables().iterator().next().getSSTableMetadata();
- assertEquals(metadata.maxLocalDeletionTime, metadata2.maxLocalDeletionTime);
- assertEquals(metadata.minTimestamp, metadata2.minTimestamp);
- assertEquals(metadata.maxTimestamp, metadata2.maxTimestamp);
- }
- @Test
- public void testTrackMetadata_rowMarkerDelete() throws Throwable
- {
- createTable("CREATE TABLE %s (a int, PRIMARY KEY (a))");
- ColumnFamilyStore cfs = Keyspace.open(keyspace()).getColumnFamilyStore(currentTable());
- execute("DELETE FROM %s USING TIMESTAMP 9999 WHERE a=1");
- cfs.forceBlockingFlush();
- assertEquals(1, cfs.getSSTables().size());
- StatsMetadata metadata = cfs.getSSTables().iterator().next().getSSTableMetadata();
- assertEquals(9999, metadata.minTimestamp);
- assertEquals(9999, metadata.maxTimestamp);
- assertEquals(System.currentTimeMillis()/1000, metadata.maxLocalDeletionTime, 5);
- cfs.forceMajorCompaction();
- StatsMetadata metadata2 = cfs.getSSTables().iterator().next().getSSTableMetadata();
- assertEquals(metadata.maxLocalDeletionTime, metadata2.maxLocalDeletionTime);
- assertEquals(metadata.minTimestamp, metadata2.minTimestamp);
- assertEquals(metadata.maxTimestamp, metadata2.maxTimestamp);
- }
-}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/f797bfa4/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
deleted file mode 100644
index b2a972b..0000000
--- a/test/unit/org/apache/cassandra/cql3/SelectWithTokenFunctionTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.cql3;
-
-import org.junit.Test;
-
-public class SelectWithTokenFunctionTest extends CQLTester
-{
- @Test
- public void testTokenFunctionWithSingleColumnPartitionKey() throws Throwable
- {
- createTable("CREATE TABLE IF NOT EXISTS %s (a int PRIMARY KEY, b text)");
- execute("INSERT INTO %s (a, b) VALUES (0, 'a')");
-
- assertRows(execute("SELECT * FROM %s WHERE token(a) >= token(?)", 0), row(0, "a"));
- assertRows(execute("SELECT * FROM %s WHERE token(a) >= token(?) and token(a) < token(?)", 0, 1), row(0, "a"));
- assertInvalid("SELECT * FROM %s WHERE token(a) > token(?)", "a");
- assertInvalid("SELECT * FROM %s WHERE token(a, b) >= token(?, ?)", "b", 0);
- assertInvalid("SELECT * FROM %s WHERE token(a) >= token(?) and token(a) >= token(?)", 0, 1);
- assertInvalid("SELECT * FROM %s WHERE token(a) >= token(?) and token(a) = token(?)", 0, 1);
- assertInvalidSyntax("SELECT * FROM %s WHERE token(a) = token(?) and token(a) IN (token(?))", 0, 1);
- }
-
- @Test
- public void testTokenFunctionWithPartitionKeyAndClusteringKeyArguments() throws Throwable
- {
- createTable("CREATE TABLE IF NOT EXISTS %s (a int, b text, PRIMARY KEY (a, b))");
- assertInvalid("SELECT * FROM %s WHERE token(a, b) > token(0, 'c')");
- }
-
- @Test
- public void testTokenFunctionWithMultiColumnPartitionKey() throws Throwable
- {
- 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 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;");
- }
-}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/f797bfa4/test/unit/org/apache/cassandra/cql3/SelectionOrderingTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/SelectionOrderingTest.java b/test/unit/org/apache/cassandra/cql3/SelectionOrderingTest.java
deleted file mode 100644
index 301aaf4..0000000
--- a/test/unit/org/apache/cassandra/cql3/SelectionOrderingTest.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.cql3;
-
-import org.junit.Test;
-
-public class SelectionOrderingTest extends CQLTester
-{
-
- @Test
- public void testNormalSelectionOrderSingleClustering() throws Throwable
- {
- for (String descOption : new String[]{"", " WITH CLUSTERING ORDER BY (b DESC)"})
- {
- createTable("CREATE TABLE %s (a int, b int, c int, PRIMARY KEY (a, b))" + descOption);
- 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);
-
- assertRows(execute("SELECT * FROM %s WHERE a=? ORDER BY b ASC", 0),
- row(0, 0, 0),
- row(0, 1, 1),
- row(0, 2, 2)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a=? ORDER BY b DESC", 0),
- row(0, 2, 2),
- row(0, 1, 1),
- row(0, 0, 0)
- );
-
- // order by the only column in the selection
- assertRows(execute("SELECT b FROM %s WHERE a=? ORDER BY b ASC", 0),
- row(0), row(1), row(2));
-
- assertRows(execute("SELECT b FROM %s WHERE a=? ORDER BY b DESC", 0),
- row(2), row(1), row(0));
-
- // order by a column not in the selection
- assertRows(execute("SELECT c FROM %s WHERE a=? ORDER BY b ASC", 0),
- row(0), row(1), row(2));
-
- assertRows(execute("SELECT c FROM %s WHERE a=? ORDER BY b DESC", 0),
- row(2), row(1), row(0));
- }
- }
-
- @Test
- public void testFunctionSelectionOrderSingleClustering() throws Throwable
- {
- for (String descOption : new String[]{"", " WITH CLUSTERING ORDER BY (b DESC)"})
- {
- createTable("CREATE TABLE %s (a int, b int, c int, PRIMARY KEY (a, b))" + descOption);
- 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);
-
- // order by the only column in the selection
- assertRows(execute("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY b ASC", 0),
- row(0), row(1), row(2));
-
- assertRows(execute("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY b DESC", 0),
- row(2), row(1), row(0));
-
- // order by a column not in the selection
- assertRows(execute("SELECT blobAsInt(intAsBlob(c)) FROM %s WHERE a=? ORDER BY b ASC", 0),
- row(0), row(1), row(2));
-
- assertRows(execute("SELECT blobAsInt(intAsBlob(c)) FROM %s WHERE a=? ORDER BY b DESC", 0),
- row(2), row(1), row(0));
-
- assertInvalid("SELECT * FROM %s WHERE a=? ORDER BY c ASC", 0);
- assertInvalid("SELECT * FROM %s WHERE a=? ORDER BY c DESC", 0);
- }
- }
-
- @Test
- public void testFieldSelectionOrderSingleClustering() throws Throwable
- {
- String type = createType("CREATE TYPE %s (a int)");
-
- for (String descOption : new String[]{"", " WITH CLUSTERING ORDER BY (b DESC)"})
- {
- createTable("CREATE TABLE %s (a int, b int, c frozen<" + type + " >, PRIMARY KEY (a, b))" + descOption);
- execute("INSERT INTO %s (a, b, c) VALUES (?, ?, {a: ?})", 0, 0, 0);
- execute("INSERT INTO %s (a, b, c) VALUES (?, ?, {a: ?})", 0, 1, 1);
- execute("INSERT INTO %s (a, b, c) VALUES (?, ?, {a: ?})", 0, 2, 2);
-
- // order by a column not in the selection
- assertRows(execute("SELECT c.a FROM %s WHERE a=? ORDER BY b ASC", 0),
- row(0), row(1), row(2));
-
- assertRows(execute("SELECT c.a FROM %s WHERE a=? ORDER BY b DESC", 0),
- row(2), row(1), row(0));
-
- assertRows(execute("SELECT blobAsInt(intAsBlob(c.a)) FROM %s WHERE a=? ORDER BY b DESC", 0),
- row(2), row(1), row(0));
- dropTable("DROP TABLE %s");
- }
- }
-
- @Test
- public void testNormalSelectionOrderMultipleClustering() throws Throwable
- {
- createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b, c))");
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 0, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 1);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 2, 2);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 0, 3);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 4);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 2, 5);
-
- assertRows(execute("SELECT * FROM %s WHERE a=? ORDER BY b ASC", 0),
- row(0, 0, 0, 0),
- row(0, 0, 1, 1),
- row(0, 0, 2, 2),
- row(0, 1, 0, 3),
- row(0, 1, 1, 4),
- row(0, 1, 2, 5)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a=? ORDER BY b DESC", 0),
- row(0, 1, 2, 5),
- row(0, 1, 1, 4),
- row(0, 1, 0, 3),
- row(0, 0, 2, 2),
- row(0, 0, 1, 1),
- row(0, 0, 0, 0)
- );
-
- assertRows(execute("SELECT * FROM %s WHERE a=? ORDER BY b DESC, c DESC", 0),
- row(0, 1, 2, 5),
- row(0, 1, 1, 4),
- row(0, 1, 0, 3),
- row(0, 0, 2, 2),
- row(0, 0, 1, 1),
- row(0, 0, 0, 0)
- );
-
- assertInvalid("SELECT * FROM %s WHERE a=? ORDER BY c ASC", 0);
- assertInvalid("SELECT * FROM %s WHERE a=? ORDER BY c DESC", 0);
- assertInvalid("SELECT * FROM %s WHERE a=? ORDER BY b ASC, c DESC", 0);
- assertInvalid("SELECT * FROM %s WHERE a=? ORDER BY b DESC, c ASC", 0);
- assertInvalid("SELECT * FROM %s WHERE a=? ORDER BY d ASC", 0);
-
- // select and order by b
- assertRows(execute("SELECT b FROM %s WHERE a=? ORDER BY b ASC", 0),
- row(0), row(0), row(0), row(1), row(1), row(1));
- assertRows(execute("SELECT b FROM %s WHERE a=? ORDER BY b DESC", 0),
- row(1), row(1), row(1), row(0), row(0), row(0));
-
- // select c, order by b
- assertRows(execute("SELECT c FROM %s WHERE a=? ORDER BY b ASC", 0),
- row(0), row(1), row(2), row(0), row(1), row(2));
- assertRows(execute("SELECT c FROM %s WHERE a=? ORDER BY b DESC", 0),
- row(2), row(1), row(0), row(2), row(1), row(0));
-
- // select c, order by b, c
- assertRows(execute("SELECT c FROM %s WHERE a=? ORDER BY b ASC, c ASC", 0),
- row(0), row(1), row(2), row(0), row(1), row(2));
- assertRows(execute("SELECT c FROM %s WHERE a=? ORDER BY b DESC, c DESC", 0),
- row(2), row(1), row(0), row(2), row(1), row(0));
-
- // select d, order by b, c
- assertRows(execute("SELECT d FROM %s WHERE a=? ORDER BY b ASC, c ASC", 0),
- row(0), row(1), row(2), row(3), row(4), row(5));
- assertRows(execute("SELECT d FROM %s WHERE a=? ORDER BY b DESC, c DESC", 0),
- row(5), row(4), row(3), row(2), row(1), row(0));
- }
-
- @Test
- public void testFunctionSelectionOrderMultipleClustering() throws Throwable
- {
- createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b, c))");
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 0, 0);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 1);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 2, 2);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 0, 3);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 4);
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 2, 5);
-
- assertInvalid("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY c ASC", 0);
- assertInvalid("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY c DESC", 0);
- assertInvalid("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY b ASC, c DESC", 0);
- assertInvalid("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY b DESC, c ASC", 0);
- assertInvalid("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY d ASC", 0);
-
- // select and order by b
- assertRows(execute("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY b ASC", 0),
- row(0), row(0), row(0), row(1), row(1), row(1));
- assertRows(execute("SELECT blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY b DESC", 0),
- row(1), row(1), row(1), row(0), row(0), row(0));
-
- assertRows(execute("SELECT b, blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY b ASC", 0),
- row(0, 0), row(0, 0), row(0, 0), row(1, 1), row(1, 1), row(1, 1));
- assertRows(execute("SELECT b, blobAsInt(intAsBlob(b)) FROM %s WHERE a=? ORDER BY b DESC", 0),
- row(1, 1), row(1, 1), row(1, 1), row(0, 0), row(0, 0), row(0, 0));
-
- // select c, order by b
- assertRows(execute("SELECT blobAsInt(intAsBlob(c)) FROM %s WHERE a=? ORDER BY b ASC", 0),
- row(0), row(1), row(2), row(0), row(1), row(2));
- assertRows(execute("SELECT blobAsInt(intAsBlob(c)) FROM %s WHERE a=? ORDER BY b DESC", 0),
- row(2), row(1), row(0), row(2), row(1), row(0));
-
- // select c, order by b, c
- assertRows(execute("SELECT blobAsInt(intAsBlob(c)) FROM %s WHERE a=? ORDER BY b ASC, c ASC", 0),
- row(0), row(1), row(2), row(0), row(1), row(2));
- assertRows(execute("SELECT blobAsInt(intAsBlob(c)) FROM %s WHERE a=? ORDER BY b DESC, c DESC", 0),
- row(2), row(1), row(0), row(2), row(1), row(0));
-
- // select d, order by b, c
- assertRows(execute("SELECT blobAsInt(intAsBlob(d)) FROM %s WHERE a=? ORDER BY b ASC, c ASC", 0),
- row(0), row(1), row(2), row(3), row(4), row(5));
- assertRows(execute("SELECT blobAsInt(intAsBlob(d)) FROM %s WHERE a=? ORDER BY b DESC, c DESC", 0),
- row(5), row(4), row(3), row(2), row(1), row(0));
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/f797bfa4/test/unit/org/apache/cassandra/cql3/SingleColumnRelationTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/SingleColumnRelationTest.java b/test/unit/org/apache/cassandra/cql3/SingleColumnRelationTest.java
deleted file mode 100644
index 604ec60..0000000
--- a/test/unit/org/apache/cassandra/cql3/SingleColumnRelationTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.cql3;
-
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class SingleColumnRelationTest extends CQLTester
-{
- @Test
- public void testInvalidCollectionEqualityRelation() throws Throwable
- {
- createTable("CREATE TABLE %s (a int PRIMARY KEY, b set<int>, c list<int>, d map<int, int>)");
- createIndex("CREATE INDEX ON %s (b)");
- createIndex("CREATE INDEX ON %s (c)");
- createIndex("CREATE INDEX ON %s (d)");
-
- assertInvalid("SELECT * FROM %s WHERE a = 0 AND b=?", set(0));
- assertInvalid("SELECT * FROM %s WHERE a = 0 AND c=?", list(0));
- assertInvalid("SELECT * FROM %s WHERE a = 0 AND d=?", map(0, 0));
- }
-
- @Test
- public void testInvalidCollectionNonEQRelation() throws Throwable
- {
- createTable("CREATE TABLE %s (a int PRIMARY KEY, b set<int>, c int)");
- createIndex("CREATE INDEX ON %s (c)");
- execute("INSERT INTO %s (a, b, c) VALUES (0, {0}, 0)");
-
- // non-EQ operators
- assertInvalid("SELECT * FROM %s WHERE c = 0 AND b > ?", set(0));
- assertInvalid("SELECT * FROM %s WHERE c = 0 AND b >= ?", set(0));
- assertInvalid("SELECT * FROM %s WHERE c = 0 AND b < ?", set(0));
- assertInvalid("SELECT * FROM %s WHERE c = 0 AND b <= ?", set(0));
- assertInvalid("SELECT * FROM %s WHERE c = 0 AND b IN (?)", set(0));
- }
-
- @Test
- public void testLargeClusteringINValues() throws Throwable
- {
- createTable("CREATE TABLE %s (k int, c int, v int, PRIMARY KEY (k, c))");
- execute("INSERT INTO %s (k, c, v) VALUES (0, 0, 0)");
- List<Integer> inValues = new ArrayList<>(10000);
- for (int i = 0; i < 10000; i++)
- inValues.add(i);
- assertRows(execute("SELECT * FROM %s WHERE k=? AND c IN ?", 0, inValues),
- row(0, 0, 0)
- );
- }
-
- @Test
- public void testMultiplePartitionKeyWithIndex() throws Throwable
- {
- createTable("CREATE TABLE %s (a int, b int, c int, d int, e int, f int, PRIMARY KEY ((a, b), c, d, e))");
- createIndex("CREATE INDEX ON %s (c)");
- createIndex("CREATE INDEX ON %s (f)");
-
- execute("INSERT INTO %s (a, b, c, d, e, f) VALUES (?, ?, ?, ?, ?, ?)", 0, 0, 0, 0, 0, 0);
- execute("INSERT INTO %s (a, b, c, d, e, f) VALUES (?, ?, ?, ?, ?, ?)", 0, 0, 0, 1, 0, 1);
- execute("INSERT INTO %s (a, b, c, d, e, f) VALUES (?, ?, ?, ?, ?, ?)", 0, 0, 0, 1, 1, 2);
-
- execute("INSERT INTO %s (a, b, c, d, e, f) VALUES (?, ?, ?, ?, ?, ?)", 0, 0, 1, 0, 0, 3);
- execute("INSERT INTO %s (a, b, c, d, e, f) VALUES (?, ?, ?, ?, ?, ?)", 0, 0, 1, 1, 0, 4);
- execute("INSERT INTO %s (a, b, c, d, e, f) VALUES (?, ?, ?, ?, ?, ?)", 0, 0, 1, 1, 1, 5);
-
- execute("INSERT INTO %s (a, b, c, d, e, f) VALUES (?, ?, ?, ?, ?, ?)", 0, 0, 2, 0, 0, 5);
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND c = ? ALLOW FILTERING", 0, 1),
- row(0, 0, 1, 0, 0, 3),
- row(0, 0, 1, 1, 0, 4),
- row(0, 0, 1, 1, 1, 5));
-
- assertRows(execute("SELECT * FROM %s WHERE a = ? AND c = ? AND d = ? ALLOW FILTERING", 0, 1, 1),
- 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",
- "SELECT * FROM %s WHERE a = ? AND c >= ? ALLOW FILTERING", 0, 1);
-
- 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 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);
- }
-}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/f797bfa4/test/unit/org/apache/cassandra/cql3/SliceQueryFilterWithTombstonesTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/SliceQueryFilterWithTombstonesTest.java b/test/unit/org/apache/cassandra/cql3/SliceQueryFilterWithTombstonesTest.java
deleted file mode 100644
index 0cb9819..0000000
--- a/test/unit/org/apache/cassandra/cql3/SliceQueryFilterWithTombstonesTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.cql3;
-
-import java.util.concurrent.TimeUnit;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.db.filter.TombstoneOverwhelmingException;
-
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.Assert.fail;
-
-/**
- * Test that TombstoneOverwhelmingException gets thrown when it should be and doesn't when it shouldn't be.
- */
-public class SliceQueryFilterWithTombstonesTest extends CQLTester
-{
- static final int ORIGINAL_THRESHOLD = DatabaseDescriptor.getTombstoneFailureThreshold();
- static final int THRESHOLD = 100;
-
- @BeforeClass
- public static void setUp() throws Throwable
- {
- DatabaseDescriptor.setTombstoneFailureThreshold(THRESHOLD);
- }
-
- @AfterClass
- public static void tearDown()
- {
- DatabaseDescriptor.setTombstoneFailureThreshold(ORIGINAL_THRESHOLD);
- }
-
- @Test
- public void testBelowThresholdSelect() throws Throwable
- {
- createTable("CREATE TABLE %s (a text, b text, c text, PRIMARY KEY (a, b));");
-
- // insert exactly the amount of tombstones that shouldn't trigger an exception
- for (int i = 0; i < THRESHOLD; i++)
- execute("INSERT INTO %s (a, b, c) VALUES ('key', 'column" + i + "', null);");
-
- try
- {
- execute("SELECT * FROM %s WHERE a = 'key';");
- }
- catch (Throwable e)
- {
- fail("SELECT with tombstones below the threshold should not have failed, but has: " + e);
- }
- }
-
- @Test
- public void testBeyondThresholdSelect() throws Throwable
- {
- createTable("CREATE TABLE %s (a text, b text, c text, PRIMARY KEY (a, b));");
-
- // insert exactly the amount of tombstones that *SHOULD* trigger an exception
- for (int i = 0; i < THRESHOLD + 1; i++)
- execute("INSERT INTO %s (a, b, c) VALUES ('key', 'column" + i + "', null);");
-
- try
- {
- execute("SELECT * FROM %s WHERE a = 'key';");
- fail("SELECT with tombstones beyond the threshold should have failed, but hasn't");
- }
- catch (Throwable e)
- {
- assertTrue(e instanceof TombstoneOverwhelmingException);
- }
- }
-
- @Test
- public void testAllShadowedSelect() throws Throwable
- {
- createTable("CREATE TABLE %s (a text, b text, c text, PRIMARY KEY (a, b));");
-
- // insert exactly the amount of tombstones that *SHOULD* normally trigger an exception
- for (int i = 0; i < THRESHOLD + 1; i++)
- execute("INSERT INTO %s (a, b, c) VALUES ('key', 'column" + i + "', null);");
-
- // delete all with a partition level tombstone
- execute("DELETE FROM %s WHERE a = 'key'");
-
- try
- {
- execute("SELECT * FROM %s WHERE a = 'key';");
- }
- catch (Throwable e)
- {
- fail("SELECT with tombstones shadowed by a partition tombstone should not have failed, but has: " + e);
- }
- }
-
- @Test
- public void testLiveShadowedCellsSelect() throws Throwable
- {
- createTable("CREATE TABLE %s (a text, b text, c text, PRIMARY KEY (a, b));");
-
- for (int i = 0; i < THRESHOLD + 1; i++)
- execute("INSERT INTO %s (a, b, c) VALUES ('key', 'column" + i + "', 'column');");
-
- // delete all with a partition level tombstone
- execute("DELETE FROM %s WHERE a = 'key'");
-
- try
- {
- execute("SELECT * FROM %s WHERE a = 'key';");
- }
- catch (Throwable e)
- {
- fail("SELECT with regular cells shadowed by a partition tombstone should not have failed, but has: " + e);
- }
- }
-
- @Test
- public void testExpiredTombstones() throws Throwable
- {
- createTable("CREATE TABLE %s (a text, b text, c text, PRIMARY KEY (a, b)) WITH gc_grace_seconds = 1;");
-
- for (int i = 0; i < THRESHOLD + 1; i++)
- execute("INSERT INTO %s (a, b, c) VALUES ('key', 'column" + i + "', null);");
-
- // not yet past gc grace - must throw a TOE
- try
- {
- execute("SELECT * FROM %s WHERE a = 'key';");
- fail("SELECT with tombstones beyond the threshold should have failed, but hasn't");
- }
- catch (Throwable e)
- {
- assertTrue(e instanceof TombstoneOverwhelmingException);
- }
-
- // sleep past gc grace
- TimeUnit.SECONDS.sleep(2);
-
- // past gc grace - must not throw a TOE now
- try
- {
- execute("SELECT * FROM %s WHERE a = 'key';");
- }
- catch (Throwable e)
- {
- fail("SELECT with expired tombstones beyond the threshold should not have failed, but has: " + e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/f797bfa4/test/unit/org/apache/cassandra/cql3/StaticColumnsQueryTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/StaticColumnsQueryTest.java b/test/unit/org/apache/cassandra/cql3/StaticColumnsQueryTest.java
deleted file mode 100644
index e27f968..0000000
--- a/test/unit/org/apache/cassandra/cql3/StaticColumnsQueryTest.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.cql3;
-
-import org.junit.Test;
-
-/**
- * Test column ranges and ordering with static column in table
- */
-public class StaticColumnsQueryTest extends CQLTester
-{
- @Test
- public void testSingleClustering() throws Throwable
- {
- createTable("CREATE TABLE %s (p text, c text, v text, s text static, PRIMARY KEY (p, c))");
-
- execute("INSERT INTO %s(p, c, v, s) values (?, ?, ?, ?)", "p1", "k1", "v1", "sv1");
- execute("INSERT INTO %s(p, c, v) values (?, ?, ?)", "p1", "k2", "v2");
- execute("INSERT INTO %s(p, s) values (?, ?)", "p2", "sv2");
-
- assertRows(execute("SELECT * FROM %s WHERE p=?", "p1"),
- row("p1", "k1", "sv1", "v1"),
- row("p1", "k2", "sv1", "v2")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=?", "p2"),
- row("p2", null, "sv2", null)
- );
-
- // Ascending order
-
- assertRows(execute("SELECT * FROM %s WHERE p=? ORDER BY c ASC", "p1"),
- row("p1", "k1", "sv1", "v1"),
- row("p1", "k2", "sv1", "v2")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? ORDER BY c ASC", "p2"),
- row("p2", null, "sv2", null)
- );
-
- // Descending order
-
- assertRows(execute("SELECT * FROM %s WHERE p=? ORDER BY c DESC", "p1"),
- row("p1", "k2", "sv1", "v2"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? ORDER BY c DESC", "p2"),
- row("p2", null, "sv2", null)
- );
-
- // No order with one relation
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=?", "p1", "k1"),
- row("p1", "k1", "sv1", "v1"),
- row("p1", "k2", "sv1", "v2")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=?", "p1", "k2"),
- row("p1", "k2", "sv1", "v2")
- );
-
- assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c>=?", "p1", "k3"));
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c =?", "p1", "k1"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c<=?", "p1", "k1"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c<=?", "p1", "k0"));
-
- // Ascending with one relation
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c ASC", "p1", "k1"),
- row("p1", "k1", "sv1", "v1"),
- row("p1", "k2", "sv1", "v2")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c ASC", "p1", "k2"),
- row("p1", "k2", "sv1", "v2")
- );
-
- assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c ASC", "p1", "k3"));
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c =? ORDER BY c ASC", "p1", "k1"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c<=? ORDER BY c ASC", "p1", "k1"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c<=? ORDER BY c ASC", "p1", "k0"));
-
- // Descending with one relation
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c DESC", "p1", "k1"),
- row("p1", "k2", "sv1", "v2"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c DESC", "p1", "k2"),
- row("p1", "k2", "sv1", "v2")
- );
-
- assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c DESC", "p1", "k3"));
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c =? ORDER BY c DESC", "p1", "k1"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c<=? ORDER BY c DESC", "p1", "k1"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c<=? ORDER BY c DESC", "p1", "k0"));
-
- // IN
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c IN (?, ?)", "p1", "k1", "k2"),
- row("p1", "k1", "sv1", "v1"),
- row("p1", "k2", "sv1", "v2")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c IN (?, ?) ORDER BY c ASC", "p1", "k1", "k2"),
- row("p1", "k1", "sv1", "v1"),
- row("p1", "k2", "sv1", "v2")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c IN (?, ?) ORDER BY c DESC", "p1", "k1", "k2"),
- row("p1", "k2", "sv1", "v2"),
- row("p1", "k1", "sv1", "v1")
- );
- }
-
- @Test
- public void testSingleClusteringReversed() throws Throwable
- {
- createTable("CREATE TABLE %s (p text, c text, v text, s text static, PRIMARY KEY (p, c)) WITH CLUSTERING ORDER BY (c DESC)");
-
- execute("INSERT INTO %s(p, c, v, s) values (?, ?, ?, ?)", "p1", "k1", "v1", "sv1");
- execute("INSERT INTO %s(p, c, v) values (?, ?, ?)", "p1", "k2", "v2");
- execute("INSERT INTO %s(p, s) values (?, ?)", "p2", "sv2");
-
- assertRows(execute("SELECT * FROM %s WHERE p=?", "p1"),
- row("p1", "k2", "sv1", "v2"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=?", "p2"),
- row("p2", null, "sv2", null)
- );
-
- // Ascending order
-
- assertRows(execute("SELECT * FROM %s WHERE p=? ORDER BY c ASC", "p1"),
- row("p1", "k1", "sv1", "v1"),
- row("p1", "k2", "sv1", "v2")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? ORDER BY c ASC", "p2"),
- row("p2", null, "sv2", null)
- );
-
- // Descending order
-
- assertRows(execute("SELECT * FROM %s WHERE p=? ORDER BY c DESC", "p1"),
- row("p1", "k2", "sv1", "v2"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? ORDER BY c DESC", "p2"),
- row("p2", null, "sv2", null)
- );
-
- // No order with one relation
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=?", "p1", "k1"),
- row("p1", "k2", "sv1", "v2"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=?", "p1", "k2"),
- row("p1", "k2", "sv1", "v2")
- );
-
- assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c>=?", "p1", "k3"));
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c=?", "p1", "k1"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c<=?", "p1", "k1"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c<=?", "p1", "k0"));
-
- // Ascending with one relation
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c ASC", "p1", "k1"),
- row("p1", "k1", "sv1", "v1"),
- row("p1", "k2", "sv1", "v2")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c ASC", "p1", "k2"),
- row("p1", "k2", "sv1", "v2")
- );
-
- assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c ASC", "p1", "k3"));
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c=? ORDER BY c ASC", "p1", "k1"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c<=? ORDER BY c ASC", "p1", "k1"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c<=? ORDER BY c ASC", "p1", "k0"));
-
- // Descending with one relation
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c DESC", "p1", "k1"),
- row("p1", "k2", "sv1", "v2"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c DESC", "p1", "k2"),
- row("p1", "k2", "sv1", "v2")
- );
-
- assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c>=? ORDER BY c DESC", "p1", "k3"));
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c=? ORDER BY c DESC", "p1", "k1"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c<=? ORDER BY c DESC", "p1", "k1"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertEmpty(execute("SELECT * FROM %s WHERE p=? AND c<=? ORDER BY c DESC", "p1", "k0"));
-
- // IN
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c IN (?, ?)", "p1", "k1", "k2"),
- row("p1", "k2", "sv1", "v2"),
- row("p1", "k1", "sv1", "v1")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c IN (?, ?) ORDER BY c ASC", "p1", "k1", "k2"),
- row("p1", "k1", "sv1", "v1"),
- row("p1", "k2", "sv1", "v2")
- );
-
- assertRows(execute("SELECT * FROM %s WHERE p=? AND c IN (?, ?) ORDER BY c DESC", "p1", "k1", "k2"),
- row("p1", "k2", "sv1", "v2"),
- row("p1", "k1", "sv1", "v1")
- );
- }
-}