cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ifesdj...@apache.org
Subject [20/25] cassandra git commit: Disallow COMPACT STORAGE syntax, avoid starting when compact tables are present
Date Mon, 06 Nov 2017 15:50:30 GMT
http://git-wip-us.apache.org/repos/asf/cassandra/blob/07fbd8ee/test/unit/org/apache/cassandra/cql3/validation/operations/SelectOrderByTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectOrderByTest.java
b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectOrderByTest.java
index a1d5743..fd44c50 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectOrderByTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectOrderByTest.java
@@ -29,72 +29,66 @@ public class SelectOrderByTest 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);
+        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);
 
-            beforeAndAfterFlush(() -> {
-                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));
-            });
-        }
+        beforeAndAfterFlush(() -> {
+            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);
+        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);
 
-            beforeAndAfterFlush(() -> {
-                // 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));
+        beforeAndAfterFlush(() -> {
+            // 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));
+            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));
+            // 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));
+            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);
-            });
-        }
+            assertInvalid("SELECT * FROM %s WHERE a=? ORDER BY c ASC", 0);
+            assertInvalid("SELECT * FROM %s WHERE a=? ORDER BY c DESC", 0);
+        });
     }
 
     @Test
@@ -102,26 +96,23 @@ public class SelectOrderByTest extends CQLTester
     {
         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);
+        createTable("CREATE TABLE %s (a int, b int, c frozen<" + type + "   >, PRIMARY
KEY (a, b))");
+        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);
 
-            beforeAndAfterFlush(() -> {
-                // 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));
+        beforeAndAfterFlush(() -> {
+            // 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 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");
-        }
+            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
@@ -245,77 +236,6 @@ public class SelectOrderByTest extends CQLTester
     }
 
     /**
-     * Check ORDER BY support in SELECT statement
-     * migrated from cql_tests.py:TestCQL.order_by_test()
-     */
-    @Test
-    public void testSimpleOrderBy() throws Throwable
-    {
-        createTable("CREATE TABLE %s (k int, c int, v int, PRIMARY KEY (k, c)) WITH COMPACT
STORAGE");
-
-        for (int i = 0; i < 10; i++)
-            execute("INSERT INTO %s (k, c, v) VALUES (0, ?, ?)", i, i);
-
-        beforeAndAfterFlush(() -> {
-            assertRows(execute("SELECT v FROM %s WHERE k = 0 ORDER BY c DESC"),
-                       row(9), row(8), row(7), row(6), row(5), row(4), row(3), row(2), row(1),
row(0));
-        });
-
-        createTable("CREATE TABLE %s (k int, c1 int, c2 int, v int, PRIMARY KEY (k, c1, c2))
WITH COMPACT STORAGE");
-
-        for (int i = 0; i < 4; i++)
-            for (int j = 0; j < 2; j++)
-                execute("INSERT INTO %s (k, c1, c2, v) VALUES (0, ?, ?, ?)", i, j, i * 2
+ j);
-
-        beforeAndAfterFlush(() -> {
-            assertInvalid("SELECT v FROM %s WHERE k = 0 ORDER BY c DESC");
-            assertInvalid("SELECT v FROM %s WHERE k = 0 ORDER BY c2 DESC");
-            assertInvalid("SELECT v FROM %s WHERE k = 0 ORDER BY k DESC");
-
-            assertRows(execute("SELECT v FROM %s WHERE k = 0 ORDER BY c1 DESC"),
-                       row(7), row(6), row(5), row(4), row(3), row(2), row(1), row(0));
-
-            assertRows(execute("SELECT v FROM %s WHERE k = 0 ORDER BY c1"),
-                       row(0), row(1), row(2), row(3), row(4), row(5), row(6), row(7));
-        });
-    }
-
-    /**
-     * More ORDER BY checks (#4160)
-     * migrated from cql_tests.py:TestCQL.more_order_by_test()
-     */
-    @Test
-    public void testMoreOrderBy() throws Throwable
-    {
-        createTable("CREATE TABLE %s (row text, number int, string text, PRIMARY KEY(row,
number)) WITH COMPACT STORAGE ");
-
-        execute("INSERT INTO %s (row, number, string) VALUES ('row', 1, 'one')");
-        execute("INSERT INTO %s (row, number, string) VALUES ('row', 2, 'two')");
-        execute("INSERT INTO %s (row, number, string) VALUES ('row', 3, 'three')");
-        execute("INSERT INTO %s (row, number, string) VALUES ('row', 4, 'four')");
-
-        beforeAndAfterFlush(() -> {
-            assertRows(execute("SELECT number FROM %s WHERE row='row' AND number < 3 ORDER
BY number ASC"),
-                       row(1), row(2));
-
-            assertRows(execute("SELECT number FROM %s WHERE row='row' AND number >= 3
ORDER BY number ASC"),
-                       row(3), row(4));
-
-            assertRows(execute("SELECT number FROM %s WHERE row='row' AND number < 3 ORDER
BY number DESC"),
-                       row(2), row(1));
-
-            assertRows(execute("SELECT number FROM %s WHERE row='row' AND number >= 3
ORDER BY number DESC"),
-                       row(4), row(3));
-
-            assertRows(execute("SELECT number FROM %s WHERE row='row' AND number > 3 ORDER
BY number DESC"),
-                       row(4));
-
-            assertRows(execute("SELECT number FROM %s WHERE row='row' AND number <= 3
ORDER BY number DESC"),
-                       row(3), row(2), row(1));
-        });
-    }
-
-    /**
      * Check we don't allow order by on row key (#4246)
      * migrated from cql_tests.py:TestCQL.order_by_validation_test()
      */

http://git-wip-us.apache.org/repos/asf/cassandra/blob/07fbd8ee/test/unit/org/apache/cassandra/cql3/validation/operations/SelectOrderedPartitionerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectOrderedPartitionerTest.java
b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectOrderedPartitionerTest.java
index 53d2a9b..a14a2a4 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectOrderedPartitionerTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectOrderedPartitionerTest.java
@@ -394,19 +394,6 @@ public class SelectOrderedPartitionerTest extends CQLTester
                    row(0, 1),
                    row(1, 0),
                    row(1, 1));
-
-        // Check for dense tables too
-        createTable(" CREATE TABLE %s (k int, c int, PRIMARY KEY (k, c)) WITH COMPACT STORAGE");
-
-        for (int k = 0; k < 2; k++)
-            for (int c = 0; c < 2; c++)
-                execute("INSERT INTO %s (k, c) VALUES (?, ?)", k, c);
-
-        assertRows(execute("SELECT * FROM %s"),
-                   row(0, 0),
-                   row(0, 1),
-                   row(1, 0),
-                   row(1, 1));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/07fbd8ee/test/unit/org/apache/cassandra/cql3/validation/operations/SelectSingleColumnRelationTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectSingleColumnRelationTest.java
b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectSingleColumnRelationTest.java
index 7e5afda..09fd464 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectSingleColumnRelationTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectSingleColumnRelationTest.java
@@ -77,23 +77,6 @@ public class SelectSingleColumnRelationTest extends CQLTester
         execute("insert into %s (a, b, c, d) values (?, ?, ?, ?)", "first", 3, 7, 3);
         execute("insert into %s (a, b, c, d) values (?, ?, ?, ?)", "second", 4, 8, 4);
 
-        testSelectQueriesWithClusteringColumnRelations();
-    }
-
-    @Test
-    public void testClusteringColumnRelationsWithCompactStorage() throws Throwable
-    {
-        createTable("CREATE TABLE %s (a text, b int, c int, d int, primary key(a, b, c))
WITH COMPACT STORAGE;");
-        execute("insert into %s (a, b, c, d) values (?, ?, ?, ?)", "first", 1, 5, 1);
-        execute("insert into %s (a, b, c, d) values (?, ?, ?, ?)", "first", 2, 6, 2);
-        execute("insert into %s (a, b, c, d) values (?, ?, ?, ?)", "first", 3, 7, 3);
-        execute("insert into %s (a, b, c, d) values (?, ?, ?, ?)", "second", 4, 8, 4);
-
-        testSelectQueriesWithClusteringColumnRelations();
-    }
-
-    private void testSelectQueriesWithClusteringColumnRelations() throws Throwable
-    {
         assertRows(execute("select * from %s where a in (?, ?)", "first", "second"),
                    row("first", 1, 5, 1),
                    row("first", 2, 6, 2),
@@ -424,36 +407,30 @@ public class SelectSingleColumnRelationTest extends CQLTester
     @Test
     public void testEmptyIN() throws Throwable
     {
-        for (String compactOption : new String[] { "", " WITH COMPACT STORAGE" })
-        {
-            createTable("CREATE TABLE %s (k1 int, k2 int, v int, PRIMARY KEY (k1, k2))" +
compactOption);
+        createTable("CREATE TABLE %s (k1 int, k2 int, v int, PRIMARY KEY (k1, k2))");
 
-            for (int i = 0; i <= 2; i++)
-                for (int j = 0; j <= 2; j++)
-                    execute("INSERT INTO %s (k1, k2, v) VALUES (?, ?, ?)", i, j, i + j);
+        for (int i = 0; i <= 2; i++)
+            for (int j = 0; j <= 2; j++)
+                execute("INSERT INTO %s (k1, k2, v) VALUES (?, ?, ?)", i, j, i + j);
 
-            assertEmpty(execute("SELECT v FROM %s WHERE k1 IN ()"));
-            assertEmpty(execute("SELECT v FROM %s WHERE k1 = 0 AND k2 IN ()"));
-        }
+        assertEmpty(execute("SELECT v FROM %s WHERE k1 IN ()"));
+        assertEmpty(execute("SELECT v FROM %s WHERE k1 = 0 AND k2 IN ()"));
     }
 
     @Test
     public void testINWithDuplicateValue() throws Throwable
     {
-        for (String compactOption : new String[] { "", " WITH COMPACT STORAGE" })
-        {
-            createTable("CREATE TABLE %s (k1 int, k2 int, v int, PRIMARY KEY (k1, k2))" +
compactOption);
-            execute("INSERT INTO %s (k1,  k2, v) VALUES (?, ?, ?)", 1, 1, 1);
+        createTable("CREATE TABLE %s (k1 int, k2 int, v int, PRIMARY KEY (k1, k2))");
+        execute("INSERT INTO %s (k1,  k2, v) VALUES (?, ?, ?)", 1, 1, 1);
 
-            assertRows(execute("SELECT * FROM %s WHERE k1 IN (?, ?)", 1, 1),
-                       row(1, 1, 1));
+        assertRows(execute("SELECT * FROM %s WHERE k1 IN (?, ?)", 1, 1),
+                   row(1, 1, 1));
 
-            assertRows(execute("SELECT * FROM %s WHERE k1 IN (?, ?) AND k2 IN (?, ?)", 1,
1, 1, 1),
-                       row(1, 1, 1));
+        assertRows(execute("SELECT * FROM %s WHERE k1 IN (?, ?) AND k2 IN (?, ?)", 1, 1,
1, 1),
+                   row(1, 1, 1));
 
-            assertRows(execute("SELECT * FROM %s WHERE k1 = ? AND k2 IN (?, ?)", 1, 1, 1),
-                       row(1, 1, 1));
-        }
+        assertRows(execute("SELECT * FROM %s WHERE k1 = ? AND k2 IN (?, ?)", 1, 1, 1),
+                   row(1, 1, 1));
     }
 
     @Test


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


Mime
View raw message