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:01 UTC

[22/31] cassandra git commit: 2.2 commit for CASSANDRA-9160

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01115f72/test/unit/org/apache/cassandra/cql3/UseStatementTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/UseStatementTest.java b/test/unit/org/apache/cassandra/cql3/UseStatementTest.java
deleted file mode 100644
index 66b4b42..0000000
--- a/test/unit/org/apache/cassandra/cql3/UseStatementTest.java
+++ /dev/null
@@ -1,29 +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 UseStatementTest extends CQLTester
-{
-    @Test
-    public void testUseStatementWithBindVariable() throws Throwable
-    {
-        assertInvalidSyntaxMessage("Bind variables cannot be used for keyspace names", "USE ?");
-    }
-}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01115f72/test/unit/org/apache/cassandra/cql3/UserTypesTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/UserTypesTest.java b/test/unit/org/apache/cassandra/cql3/UserTypesTest.java
deleted file mode 100644
index bfd3e9f..0000000
--- a/test/unit/org/apache/cassandra/cql3/UserTypesTest.java
+++ /dev/null
@@ -1,334 +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 UserTypesTest extends CQLTester
-{
-    @Test
-    public void testInvalidField() throws Throwable
-    {
-        String myType = createType("CREATE TYPE %s (f int)");
-        createTable("CREATE TABLE %s (k int PRIMARY KEY, v frozen<" + myType + ">)");
-
-        // 's' is not a field of myType
-        assertInvalid("INSERT INTO %s (k, v) VALUES (?, {s : ?})", 0, 1);
-    }
-
-    @Test
-    public void testCassandra8105() throws Throwable
-    {
-        String ut1 = createType("CREATE TYPE %s (a int, b int)");
-        String ut2 = createType("CREATE TYPE %s (j frozen<" + KEYSPACE + "." + ut1 + ">, k int)");
-        createTable("CREATE TABLE %s (x int PRIMARY KEY, y set<frozen<" + KEYSPACE + "." + ut2 + ">>)");
-        execute("INSERT INTO %s (x, y) VALUES (1, { { k: 1 } })");
-
-        String ut3 = createType("CREATE TYPE %s (a int, b int)");
-        String ut4 = createType("CREATE TYPE %s (j frozen<" + KEYSPACE + "." + ut3 + ">, k int)");
-        createTable("CREATE TABLE %s (x int PRIMARY KEY, y list<frozen<" + KEYSPACE + "." + ut4 + ">>)");
-        execute("INSERT INTO %s (x, y) VALUES (1, [ { k: 1 } ])");
-
-        String ut5 = createType("CREATE TYPE %s (a int, b int)");
-        String ut6 = createType("CREATE TYPE %s (i int, j frozen<" + KEYSPACE + "." + ut5 + ">)");
-        createTable("CREATE TABLE %s (x int PRIMARY KEY, y set<frozen<" + KEYSPACE + "." + ut6 + ">>)");
-        execute("INSERT INTO %s (x, y) VALUES (1, { { i: 1 } })");
-    }
-
-    @Test
-    public void testFor7684() throws Throwable
-    {
-        String myType = createType("CREATE TYPE %s (x double)");
-        createTable("CREATE TABLE %s (k int, v frozen<" + myType + ">, b boolean static, PRIMARY KEY (k, v))");
-
-        execute("INSERT INTO %s(k, v) VALUES (?, {x:?})", 1, -104.99251);
-        execute("UPDATE %s SET b = ? WHERE k = ?", true, 1);
-
-        assertRows(execute("SELECT v.x FROM %s WHERE k = ? AND v = {x:?}", 1, -104.99251),
-            row(-104.99251)
-        );
-
-        flush();
-
-        assertRows(execute("SELECT v.x FROM %s WHERE k = ? AND v = {x:?}", 1, -104.99251),
-            row(-104.99251)
-        );
-    }
-
-    @Test
-    public void testCreateInvalidTablesWithUDT() throws Throwable
-    {
-        String myType = createType("CREATE TYPE %s (f int)");
-
-        // Using a UDT without frozen shouldn't work
-        assertInvalidMessage("Non-frozen User-Defined types are not supported, please use frozen<>",
-                             "CREATE TABLE " + KEYSPACE + ".wrong (k int PRIMARY KEY, v " + KEYSPACE + '.' + myType + ")");
-
-        assertInvalidMessage("Statement on keyspace " + KEYSPACE + " cannot refer to a user type in keyspace otherkeyspace;" +
-                             " user types can only be used in the keyspace they are defined in",
-                             "CREATE TABLE " + KEYSPACE + ".wrong (k int PRIMARY KEY, v frozen<otherKeyspace.myType>)");
-
-        assertInvalidMessage("Unknown type " + KEYSPACE + ".unknowntype",
-                             "CREATE TABLE " + KEYSPACE + ".wrong (k int PRIMARY KEY, v frozen<" + KEYSPACE + '.' + "unknownType>)");
-    }
-
-    @Test
-    public void testAlterUDT() throws Throwable
-    {
-        String myType = KEYSPACE + '.' + createType("CREATE TYPE %s (a int)");
-        createTable("CREATE TABLE %s (a int PRIMARY KEY, b frozen<" + myType + ">)");
-        execute("INSERT INTO %s (a, b) VALUES (1, {a: 1})");
-
-        assertRows(execute("SELECT b.a FROM %s"), row(1));
-
-        flush();
-
-        execute("ALTER TYPE " + myType + " ADD b int");
-        execute("INSERT INTO %s (a, b) VALUES (2, {a: 2, b :2})");
-
-        assertRows(execute("SELECT b.a, b.b FROM %s"),
-                   row(1, null),
-                   row(2, 2));
-
-        flush();
-
-        assertRows(execute("SELECT b.a, b.b FROM %s"),
-                   row(1, null),
-                   row(2, 2));
-    }
-
-    @Test
-    public void testUDTWithUnsetValues() throws Throwable
-    {
-        // set up
-        String myType = createType("CREATE TYPE %s (x int, y int)");
-        String myOtherType = createType("CREATE TYPE %s (a frozen<" + myType + ">)");
-        createTable("CREATE TABLE %s (k int PRIMARY KEY, v frozen<" + myType + ">, z frozen<" + myOtherType + ">)");
-
-        assertInvalidMessage("Invalid unset value for field 'y' of user defined type " + myType,
-                "INSERT INTO %s (k, v) VALUES (10, {x:?, y:?})", 1, unset());
-
-        assertInvalidMessage("Invalid unset value for field 'y' of user defined type " + myType,
-                "INSERT INTO %s (k, v, z) VALUES (10, {x:?, y:?}, {a:{x: ?, y: ?}})", 1, 1, 1, unset());
-    }
-
-    @Test
-    public void testAlteringUserTypeNestedWithinMap() throws Throwable
-    {
-        // test frozen and non-frozen collections
-        String[] columnTypePrefixes = {"frozen<map<text, ", "map<text, frozen<"};
-        for (String columnTypePrefix : columnTypePrefixes)
-        {
-            String ut1 = createType("CREATE TYPE %s (a int)");
-            String columnType = columnTypePrefix + KEYSPACE + "." + ut1 + ">>";
-
-            createTable("CREATE TABLE %s (x int PRIMARY KEY, y " + columnType + ")");
-
-            execute("INSERT INTO %s (x, y) VALUES(1, {'firstValue':{a:1}})");
-            assertRows(execute("SELECT * FROM %s"), row(1, map("firstValue", userType(1))));
-            flush();
-
-            execute("ALTER TYPE " + KEYSPACE + "." + ut1 + " ADD b int");
-            execute("INSERT INTO %s (x, y) VALUES(2, {'secondValue':{a:2, b:2}})");
-            execute("INSERT INTO %s (x, y) VALUES(3, {'thirdValue':{a:3}})");
-            execute("INSERT INTO %s (x, y) VALUES(4, {'fourthValue':{b:4}})");
-
-            assertRows(execute("SELECT * FROM %s"),
-                    row(1, map("firstValue", userType(1))),
-                    row(2, map("secondValue", userType(2, 2))),
-                    row(3, map("thirdValue", userType(3, null))),
-                    row(4, map("fourthValue", userType(null, 4))));
-
-            flush();
-
-            assertRows(execute("SELECT * FROM %s"),
-                    row(1, map("firstValue", userType(1))),
-                    row(2, map("secondValue", userType(2, 2))),
-                    row(3, map("thirdValue", userType(3, null))),
-                    row(4, map("fourthValue", userType(null, 4))));
-        }
-    }
-
-    @Test
-    public void testAlteringUserTypeNestedWithinSet() throws Throwable
-    {
-        // test frozen and non-frozen collections
-        String[] columnTypePrefixes = {"frozen<set<", "set<frozen<"};
-        for (String columnTypePrefix : columnTypePrefixes)
-        {
-            String ut1 = createType("CREATE TYPE %s (a int)");
-            String columnType = columnTypePrefix + KEYSPACE + "." + ut1 + ">>";
-
-            createTable("CREATE TABLE %s (x int PRIMARY KEY, y " + columnType + ")");
-
-            execute("INSERT INTO %s (x, y) VALUES(1, {1} )");
-            assertRows(execute("SELECT * FROM %s"), row(1, set(userType(1))));
-            flush();
-
-            execute("ALTER TYPE " + KEYSPACE + "." + ut1 + " ADD b int");
-            execute("INSERT INTO %s (x, y) VALUES(2, {{a:2, b:2}})");
-            execute("INSERT INTO %s (x, y) VALUES(3, {{a:3}})");
-            execute("INSERT INTO %s (x, y) VALUES(4, {{b:4}})");
-
-            assertRows(execute("SELECT * FROM %s"),
-                    row(1, set(userType(1))),
-                    row(2, set(userType(2, 2))),
-                    row(3, set(userType(3, null))),
-                    row(4, set(userType(null, 4))));
-
-            flush();
-
-            assertRows(execute("SELECT * FROM %s"),
-                    row(1, set(userType(1))),
-                    row(2, set(userType(2, 2))),
-                    row(3, set(userType(3, null))),
-                    row(4, set(userType(null, 4))));
-        }
-    }
-
-    @Test
-    public void testAlteringUserTypeNestedWithinList() throws Throwable
-    {
-        // test frozen and non-frozen collections
-        String[] columnTypePrefixes = {"frozen<list<", "list<frozen<"};
-        for (String columnTypePrefix : columnTypePrefixes)
-        {
-            String ut1 = createType("CREATE TYPE %s (a int)");
-            String columnType = columnTypePrefix + KEYSPACE + "." + ut1 + ">>";
-
-            createTable("CREATE TABLE %s (x int PRIMARY KEY, y " + columnType + ")");
-
-            execute("INSERT INTO %s (x, y) VALUES(1, [1] )");
-            assertRows(execute("SELECT * FROM %s"), row(1, list(userType(1))));
-            flush();
-
-            execute("ALTER TYPE " + KEYSPACE + "." + ut1 + " ADD b int");
-            execute("INSERT INTO %s (x, y) VALUES(2, [{a:2, b:2}])");
-            execute("INSERT INTO %s (x, y) VALUES(3, [{a:3}])");
-            execute("INSERT INTO %s (x, y) VALUES(4, [{b:4}])");
-
-            assertRows(execute("SELECT * FROM %s"),
-                    row(1, list(userType(1))),
-                    row(2, list(userType(2, 2))),
-                    row(3, list(userType(3, null))),
-                    row(4, list(userType(null, 4))));
-
-            flush();
-
-            assertRows(execute("SELECT * FROM %s"),
-                    row(1, list(userType(1))),
-                    row(2, list(userType(2, 2))),
-                    row(3, list(userType(3, null))),
-                    row(4, list(userType(null, 4))));
-        }
-    }
-
-    @Test
-    public void testAlteringUserTypeNestedWithinTuple() throws Throwable
-    {
-        String type = createType("CREATE TYPE %s (a int, b int)");
-
-        createTable("CREATE TABLE %s (a int PRIMARY KEY, b frozen<tuple<int, " + KEYSPACE + "." + type + ">>)");
-
-        execute("INSERT INTO %s (a, b) VALUES(1, (1, {a:1, b:1}))");
-        assertRows(execute("SELECT * FROM %s"), row(1, tuple(1, userType(1, 1))));
-        flush();
-
-        execute("ALTER TYPE " + KEYSPACE + "." + type + " ADD c int");
-        execute("INSERT INTO %s (a, b) VALUES(2, (2, {a: 2, b: 2, c: 2}))");
-        execute("INSERT INTO %s (a, b) VALUES(3, (3, {a: 3, b: 3}))");
-        execute("INSERT INTO %s (a, b) VALUES(4, (4, {b:4}))");
-
-        assertRows(execute("SELECT * FROM %s"),
-                   row(1, tuple(1, userType(1, 1))),
-                   row(2, tuple(2, userType(2, 2, 2))),
-                   row(3, tuple(3, userType(3, 3, null))),
-                   row(4, tuple(4, userType(null, 4, null))));
-
-        flush();
-
-        assertRows(execute("SELECT * FROM %s"),
-                   row(1, tuple(1, userType(1, 1))),
-                   row(2, tuple(2, userType(2, 2, 2))),
-                   row(3, tuple(3, userType(3, 3, null))),
-                   row(4, tuple(4, userType(null, 4, null))));
-    }
-
-    @Test
-    public void testAlteringUserTypeNestedWithinNestedTuple() throws Throwable
-    {
-        String type = createType("CREATE TYPE %s (a int, b int)");
-
-        createTable("CREATE TABLE %s (a int PRIMARY KEY, b frozen<tuple<int, tuple<int, " + KEYSPACE + "." + type + ">>>)");
-
-        execute("INSERT INTO %s (a, b) VALUES(1, (1, (1, {a:1, b:1})))");
-        assertRows(execute("SELECT * FROM %s"), row(1, tuple(1, tuple(1, userType(1, 1)))));
-        flush();
-
-        execute("ALTER TYPE " + KEYSPACE + "." + type + " ADD c int");
-        execute("INSERT INTO %s (a, b) VALUES(2, (2, (1, {a: 2, b: 2, c: 2})))");
-        execute("INSERT INTO %s (a, b) VALUES(3, (3, (1, {a: 3, b: 3})))");
-        execute("INSERT INTO %s (a, b) VALUES(4, (4, (1, {b:4})))");
-
-        assertRows(execute("SELECT * FROM %s"),
-                   row(1, tuple(1, tuple(1, userType(1, 1)))),
-                   row(2, tuple(2, tuple(1, userType(2, 2, 2)))),
-                   row(3, tuple(3, tuple(1, userType(3, 3, null)))),
-                   row(4, tuple(4, tuple(1, userType(null, 4, null)))));
-
-        flush();
-
-        assertRows(execute("SELECT * FROM %s"),
-                   row(1, tuple(1, tuple(1, userType(1, 1)))),
-                   row(2, tuple(2, tuple(1, userType(2, 2, 2)))),
-                   row(3, tuple(3, tuple(1, userType(3, 3, null)))),
-                   row(4, tuple(4, tuple(1, userType(null, 4, null)))));
-    }
-
-    @Test
-    public void testAlteringUserTypeNestedWithinUserType() throws Throwable
-    {
-        String type = createType("CREATE TYPE %s (a int, b int)");
-        String otherType = createType("CREATE TYPE %s (x frozen<" + KEYSPACE + "." + type + ">)");
-
-        createTable("CREATE TABLE %s (a int PRIMARY KEY, b frozen<" + KEYSPACE + "." + otherType + ">)");
-
-        execute("INSERT INTO %s (a, b) VALUES(1, {x: {a:1, b:1}})");
-        assertRows(execute("SELECT b.x.a, b.x.b FROM %s"), row(1, 1));
-        flush();
-
-        execute("ALTER TYPE " + KEYSPACE + "." + type + " ADD c int");
-        execute("INSERT INTO %s (a, b) VALUES(2, {x: {a: 2, b: 2, c: 2}})");
-        execute("INSERT INTO %s (a, b) VALUES(3, {x: {a: 3, b: 3}})");
-        execute("INSERT INTO %s (a, b) VALUES(4, {x: {b:4}})");
-
-        assertRows(execute("SELECT b.x.a, b.x.b, b.x.c FROM %s"),
-                   row(1, 1, null),
-                   row(2, 2, 2),
-                   row(3, 3, null),
-                   row(null, 4, null));
-
-        flush();
-
-        assertRows(execute("SELECT b.x.a, b.x.b, b.x.c FROM %s"),
-                   row(1, 1, null),
-                   row(2, 2, 2),
-                   row(3, 3, null),
-                   row(null, 4, null));
-    }
-}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01115f72/test/unit/org/apache/cassandra/cql3/selection/SelectionColumnMappingTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/selection/SelectionColumnMappingTest.java b/test/unit/org/apache/cassandra/cql3/selection/SelectionColumnMappingTest.java
index 5bacf0d..2f1d361 100644
--- a/test/unit/org/apache/cassandra/cql3/selection/SelectionColumnMappingTest.java
+++ b/test/unit/org/apache/cassandra/cql3/selection/SelectionColumnMappingTest.java
@@ -3,13 +3,16 @@ package org.apache.cassandra.cql3.selection;
 import java.util.Collections;
 
 import com.google.common.collect.ImmutableList;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 import org.apache.cassandra.config.ColumnDefinition;
+import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.cql3.statements.SelectStatement;
 import org.apache.cassandra.db.marshal.*;
+import org.apache.cassandra.dht.ByteOrderedPartitioner;
 import org.apache.cassandra.exceptions.RequestValidationException;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.utils.ByteBufferUtil;
@@ -25,6 +28,12 @@ public class SelectionColumnMappingTest extends CQLTester
     UserType userType;
     String functionName;
 
+    @BeforeClass
+    public static void setUpClass()
+    {
+        DatabaseDescriptor.setPartitioner(ByteOrderedPartitioner.instance);
+    }
+
     @Test
     public void testSelectionColumnMapping() throws Throwable
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01115f72/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
new file mode 100644
index 0000000..2e72c39
--- /dev/null
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java
@@ -0,0 +1,588 @@
+/*
+ * 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.validation.entities;
+
+import java.util.UUID;
+
+import org.junit.Test;
+
+import org.apache.cassandra.cql3.CQLTester;
+
+public class CollectionsTest extends CQLTester
+{
+    @Test
+    public void testMapBulkRemoval() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k int PRIMARY KEY, m map<text, text>)");
+
+        execute("INSERT INTO %s(k, m) VALUES (?, ?)", 0, map("k1", "v1", "k2", "v2", "k3", "v3"));
+
+        assertRows(execute("SELECT * FROM %s"),
+            row(0, map("k1", "v1", "k2", "v2", "k3", "v3"))
+        );
+
+        execute("UPDATE %s SET m = m - ? WHERE k = ?", set("k2"), 0);
+
+        assertRows(execute("SELECT * FROM %s"),
+            row(0, map("k1", "v1", "k3", "v3"))
+        );
+
+        execute("UPDATE %s SET m = m + ?, m = m - ? WHERE k = ?", map("k4", "v4"), set("k3"), 0);
+
+        assertRows(execute("SELECT * FROM %s"),
+            row(0, map("k1", "v1", "k4", "v4"))
+        );
+    }
+
+    @Test
+    public void testInvalidCollectionsMix() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k int PRIMARY KEY, l list<text>, s set<text>, m map<text, text>)");
+
+        // Note: we force the non-prepared form for some of those tests because a list and a set
+        // have the same serialized format in practice and CQLTester don't validate that the type
+        // of what's passed as a value in the prepared case, so the queries would work (which is ok,
+        // CQLTester is just a "dumb" client).
+
+        assertInvalid("UPDATE %s SET l = l + { 'a', 'b' } WHERE k = 0");
+        assertInvalid("UPDATE %s SET l = l - { 'a', 'b' } WHERE k = 0");
+        assertInvalid("UPDATE %s SET l = l + ? WHERE k = 0", map("a", "b", "c", "d"));
+        assertInvalid("UPDATE %s SET l = l - ? WHERE k = 0", map("a", "b", "c", "d"));
+
+        assertInvalid("UPDATE %s SET s = s + [ 'a', 'b' ] WHERE k = 0");
+        assertInvalid("UPDATE %s SET s = s - [ 'a', 'b' ] WHERE k = 0");
+        assertInvalid("UPDATE %s SET s = s + ? WHERE k = 0", map("a", "b", "c", "d"));
+        assertInvalid("UPDATE %s SET s = s - ? WHERE k = 0", map("a", "b", "c", "d"));
+
+        assertInvalid("UPDATE %s SET m = m + ? WHERE k = 0", list("a", "b"));
+        assertInvalid("UPDATE %s SET m = m - [ 'a', 'b' ] WHERE k = 0");
+        assertInvalid("UPDATE %s SET m = m + ? WHERE k = 0", set("a", "b"));
+        assertInvalid("UPDATE %s SET m = m - ? WHERE k = 0", map("a", "b", "c", "d"));
+    }
+
+    @Test
+    public void testSets() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k int PRIMARY KEY, s set<text>)");
+
+        execute("INSERT INTO %s(k, s) VALUES (0, ?)", set("v1", "v2", "v3", "v4"));
+
+        assertRows(execute("SELECT s FROM %s WHERE k = 0"),
+            row(set("v1", "v2", "v3", "v4"))
+        );
+
+        execute("DELETE s[?] FROM %s WHERE k = 0", "v1");
+
+        assertRows(execute("SELECT s FROM %s WHERE k = 0"),
+                   row(set("v2", "v3", "v4"))
+        );
+
+        // Full overwrite
+        execute("UPDATE %s SET s = ? WHERE k = 0", set("v6", "v5"));
+
+        assertRows(execute("SELECT s FROM %s WHERE k = 0"),
+                   row(set("v5", "v6"))
+        );
+
+        execute("UPDATE %s SET s = s + ? WHERE k = 0", set("v7"));
+
+        assertRows(execute("SELECT s FROM %s WHERE k = 0"),
+                   row(set("v5", "v6", "v7"))
+        );
+
+        execute("UPDATE %s SET s = s - ? WHERE k = 0", set("v6", "v5"));
+
+        assertRows(execute("SELECT s FROM %s WHERE k = 0"),
+                   row(set("v7"))
+        );
+
+        execute("DELETE s[?] FROM %s WHERE k = 0", set("v7"));
+
+        // Deleting an element that does not exist will succeed
+        execute("DELETE s[?] FROM %s WHERE k = 0", set("v7"));
+
+        execute("DELETE s FROM %s WHERE k = 0");
+
+        assertRows(execute("SELECT s FROM %s WHERE k = 0"),
+                   row((Object) null)
+        );
+    }
+
+    @Test
+    public void testMaps() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k int PRIMARY KEY, m map<text, int>)");
+
+        execute("INSERT INTO %s(k, m) VALUES (0, ?)", map("v1", 1, "v2", 2));
+
+        assertRows(execute("SELECT m FROM %s WHERE k = 0"),
+            row(map("v1", 1, "v2", 2))
+        );
+
+        execute("UPDATE %s SET m[?] = ?, m[?] = ? WHERE k = 0", "v3", 3, "v4", 4);
+
+        assertRows(execute("SELECT m FROM %s WHERE k = 0"),
+            row(map("v1", 1, "v2", 2, "v3", 3, "v4", 4))
+        );
+
+        execute("DELETE m[?] FROM %s WHERE k = 0", "v1");
+
+        assertRows(execute("SELECT m FROM %s WHERE k = 0"),
+            row(map("v2", 2, "v3", 3, "v4", 4))
+        );
+
+        // Full overwrite
+        execute("UPDATE %s SET m = ? WHERE k = 0", map("v6", 6, "v5", 5));
+
+        assertRows(execute("SELECT m FROM %s WHERE k = 0"),
+                   row(map("v5", 5, "v6", 6))
+        );
+
+        execute("UPDATE %s SET m = m + ? WHERE k = 0", map("v7", 7));
+
+        assertRows(execute("SELECT m FROM %s WHERE k = 0"),
+                   row(map("v5", 5, "v6", 6, "v7", 7))
+        );
+
+        execute("DELETE m[?] FROM %s WHERE k = 0", "v7");
+
+        assertRows(execute("SELECT m FROM %s WHERE k = 0"),
+                   row(map("v5", 5, "v6", 6))
+        );
+
+        execute("DELETE m[?] FROM %s WHERE k = 0", "v6");
+
+        assertRows(execute("SELECT m FROM %s WHERE k = 0"),
+                   row(map("v5", 5))
+        );
+
+        execute("DELETE m[?] FROM %s WHERE k = 0", "v5");
+
+        assertRows(execute("SELECT m FROM %s WHERE k = 0"),
+                   row((Object) null)
+        );
+
+        // Deleting a non-existing key should succeed
+        execute("DELETE m[?] FROM %s WHERE k = 0", "v5");
+
+        assertRows(execute("SELECT m FROM %s WHERE k = 0"),
+                   row((Object) null)
+        );
+
+        // The empty map is parsed as an empty set (because we don't have enough info at parsing
+        // time when we see a {}) and special cased later. This test checks this work properly
+        execute("UPDATE %s SET m = {} WHERE k = 0");
+
+        assertRows(execute("SELECT m FROM %s WHERE k = 0"),
+            row((Object)null)
+        );
+    }
+
+    @Test
+    public void testLists() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k int PRIMARY KEY, l list<text>)");
+
+        execute("INSERT INTO %s(k, l) VALUES (0, ?)", list("v1", "v2", "v3"));
+
+        assertRows(execute("SELECT l FROM %s WHERE k = 0"), row(list("v1", "v2", "v3")));
+
+        execute("DELETE l[?] FROM %s WHERE k = 0", 1);
+
+        assertRows(execute("SELECT l FROM %s WHERE k = 0"), row(list("v1", "v3")));
+
+        execute("UPDATE %s SET l[?] = ? WHERE k = 0", 1, "v4");
+
+        assertRows(execute("SELECT l FROM %s WHERE k = 0"), row(list("v1", "v4")));
+
+        // Full overwrite
+        execute("UPDATE %s SET l = ? WHERE k = 0", list("v6", "v5"));
+
+        assertRows(execute("SELECT l FROM %s WHERE k = 0"), row(list("v6", "v5")));
+
+        execute("UPDATE %s SET l = l + ? WHERE k = 0", list("v7", "v8"));
+
+        assertRows(execute("SELECT l FROM %s WHERE k = 0"), row(list("v6", "v5", "v7", "v8")));
+
+        execute("UPDATE %s SET l = ? + l WHERE k = 0", list("v9"));
+
+        assertRows(execute("SELECT l FROM %s WHERE k = 0"), row(list("v9", "v6", "v5", "v7", "v8")));
+
+        execute("UPDATE %s SET l = l - ? WHERE k = 0", list("v5", "v8"));
+
+        assertRows(execute("SELECT l FROM %s WHERE k = 0"), row(list("v9", "v6", "v7")));
+
+        execute("DELETE l FROM %s WHERE k = 0");
+
+        assertRows(execute("SELECT l FROM %s WHERE k = 0"), row((Object) null));
+
+        assertInvalidMessage("Attempted to delete an element from a list which is null",
+                             "DELETE l[0] FROM %s WHERE k=0 ");
+
+        assertInvalidMessage("Attempted to set an element on a list which is null",
+                             "UPDATE %s SET l[0] = ? WHERE k=0", list("v10"));
+
+        execute("UPDATE %s SET l = l - ? WHERE k=0 ", list("v11"));
+
+        assertRows(execute("SELECT l FROM %s WHERE k = 0"), row((Object) null));
+    }
+
+    @Test
+    public void testMapWithUnsetValues() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k int PRIMARY KEY, m map<text,text>)");
+        // set up
+        Object m = map("k", "v");
+        execute("INSERT INTO %s (k, m) VALUES (10, ?)", m);
+        assertRows(execute("SELECT m FROM %s WHERE k = 10"),
+                   row(m)
+        );
+
+        // test putting an unset map, should not delete the contents
+        execute("INSERT INTO %s (k, m) VALUES (10, ?)", unset());
+        assertRows(execute("SELECT m FROM %s WHERE k = 10"),
+                   row(m)
+        );
+        // test unset variables in a map update operaiotn, should not delete the contents
+        execute("UPDATE %s SET m['k'] = ? WHERE k = 10", unset());
+        assertRows(execute("SELECT m FROM %s WHERE k = 10"),
+                   row(m)
+        );
+        assertInvalidMessage("Invalid unset map key", "UPDATE %s SET m[?] = 'foo' WHERE k = 10", unset());
+
+        // test unset value for map key
+        assertInvalidMessage("Invalid unset map key", "DELETE m[?] FROM %s WHERE k = 10", unset());
+    }
+
+    @Test
+    public void testListWithUnsetValues() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k int PRIMARY KEY, l list<text>)");
+        // set up
+        Object l = list("foo", "foo");
+        execute("INSERT INTO %s (k, l) VALUES (10, ?)", l);
+        assertRows(execute("SELECT l FROM %s WHERE k = 10"),
+                   row(l)
+        );
+
+        // replace list with unset value
+        execute("INSERT INTO %s (k, l) VALUES (10, ?)", unset());
+        assertRows(execute("SELECT l FROM %s WHERE k = 10"),
+                   row(l)
+        );
+
+        // add to position
+        execute("UPDATE %s SET l[1] = ? WHERE k = 10", unset());
+        assertRows(execute("SELECT l FROM %s WHERE k = 10"),
+                   row(l)
+        );
+
+        // set in index
+        assertInvalidMessage("Invalid unset value for list index", "UPDATE %s SET l[?] = 'foo' WHERE k = 10", unset());
+
+        // remove element by index
+        execute("DELETE l[?] FROM %s WHERE k = 10", unset());
+        assertRows(execute("SELECT l FROM %s WHERE k = 10"),
+                   row(l)
+        );
+
+        // remove all occurrences of element
+        execute("UPDATE %s SET l = l - ? WHERE k = 10", unset());
+        assertRows(execute("SELECT l FROM %s WHERE k = 10"),
+                   row(l)
+        );
+
+        // select with in clause
+        assertInvalidMessage("Invalid unset value for column k", "SELECT * FROM %s WHERE k IN ?", unset());
+        assertInvalidMessage("Invalid unset value for column k", "SELECT * FROM %s WHERE k IN (?)", unset());
+    }
+
+    @Test
+    public void testSetWithUnsetValues() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k int PRIMARY KEY, s set<text>)");
+
+        Object s = set("bar", "baz", "foo");
+        execute("INSERT INTO %s (k, s) VALUES (10, ?)", s);
+        assertRows(execute("SELECT s FROM %s WHERE k = 10"),
+                   row(s)
+        );
+
+        // replace set with unset value
+        execute("INSERT INTO %s (k, s) VALUES (10, ?)", unset());
+        assertRows(execute("SELECT s FROM %s WHERE k = 10"),
+                   row(s)
+        );
+
+        // add to set
+        execute("UPDATE %s SET s = s + ? WHERE k = 10", unset());
+        assertRows(execute("SELECT s FROM %s WHERE k = 10"),
+                   row(s)
+        );
+
+        // remove all occurrences of element
+        execute("UPDATE %s SET s = s - ? WHERE k = 10", unset());
+        assertRows(execute("SELECT s FROM %s WHERE k = 10"),
+                   row(s)
+        );
+    }
+
+    /**
+     * Migrated from cql_tests.py:TestCQL.set_test()
+     */
+    @Test
+    public void testSet() throws Throwable
+    {
+        createTable("CREATE TABLE %s ( fn text, ln text, tags set<text>, PRIMARY KEY (fn, ln) )");
+
+        execute("UPDATE %s SET tags = tags + { 'foo' } WHERE fn='Tom' AND ln='Bombadil'");
+        execute("UPDATE %s SET tags = tags + { 'bar' } WHERE fn='Tom' AND ln='Bombadil'");
+        execute("UPDATE %s SET tags = tags + { 'foo' } WHERE fn='Tom' AND ln='Bombadil'");
+        execute("UPDATE %s SET tags = tags + { 'foobar' } WHERE fn='Tom' AND ln='Bombadil'");
+        execute("UPDATE %s SET tags = tags - { 'bar' } WHERE fn='Tom' AND ln='Bombadil'");
+
+        assertRows(execute("SELECT tags FROM %s"),
+                   row(set("foo", "foobar")));
+
+        execute("UPDATE %s SET tags = { 'a', 'c', 'b' } WHERE fn='Bilbo' AND ln='Baggins'");
+        assertRows(execute("SELECT tags FROM %s WHERE fn='Bilbo' AND ln='Baggins'"),
+                   row(set("a", "b", "c")));
+
+        execute("UPDATE %s SET tags = { 'm', 'n' } WHERE fn='Bilbo' AND ln='Baggins'");
+        assertRows(execute("SELECT tags FROM %s WHERE fn='Bilbo' AND ln='Baggins'"),
+                   row(set("m", "n")));
+
+        execute("DELETE tags['m'] FROM %s WHERE fn='Bilbo' AND ln='Baggins'");
+        assertRows(execute("SELECT tags FROM %s WHERE fn='Bilbo' AND ln='Baggins'"),
+                   row(set("n")));
+
+        execute("DELETE tags FROM %s WHERE fn='Bilbo' AND ln='Baggins'");
+        assertEmpty(execute("SELECT tags FROM %s WHERE fn='Bilbo' AND ln='Baggins'"));
+    }
+
+    /**
+     * Migrated from cql_tests.py:TestCQL.map_test()
+     */
+    @Test
+    public void testMap() throws Throwable
+    {
+        createTable("CREATE TABLE %s (fn text, ln text, m map<text, int>, PRIMARY KEY (fn, ln))");
+
+        execute("UPDATE %s SET m['foo'] = 3 WHERE fn='Tom' AND ln='Bombadil'");
+        execute("UPDATE %s SET m['bar'] = 4 WHERE fn='Tom' AND ln='Bombadil'");
+        execute("UPDATE %s SET m['woot'] = 5 WHERE fn='Tom' AND ln='Bombadil'");
+        execute("UPDATE %s SET m['bar'] = 6 WHERE fn='Tom' AND ln='Bombadil'");
+        execute("DELETE m['foo'] FROM %s WHERE fn='Tom' AND ln='Bombadil'");
+
+        assertRows(execute("SELECT m FROM %s"),
+                   row(map("bar", 6, "woot", 5)));
+
+        execute("UPDATE %s SET m = { 'a' : 4 , 'c' : 3, 'b' : 2 } WHERE fn='Bilbo' AND ln='Baggins'");
+        assertRows(execute("SELECT m FROM %s WHERE fn='Bilbo' AND ln='Baggins'"),
+                   row(map("a", 4, "b", 2, "c", 3)));
+
+        execute("UPDATE %s SET m =  { 'm' : 4 , 'n' : 1, 'o' : 2 } WHERE fn='Bilbo' AND ln='Baggins'");
+        assertRows(execute("SELECT m FROM %s WHERE fn='Bilbo' AND ln='Baggins'"),
+                   row(map("m", 4, "n", 1, "o", 2)));
+
+        execute("UPDATE %s SET m = {} WHERE fn='Bilbo' AND ln='Baggins'");
+        assertEmpty(execute("SELECT m FROM %s WHERE fn='Bilbo' AND ln='Baggins'"));
+    }
+
+    /**
+     * Migrated from cql_tests.py:TestCQL.list_test()
+     */
+    @Test
+    public void testList() throws Throwable
+    {
+        createTable("CREATE TABLE %s (fn text, ln text, tags list<text>, PRIMARY KEY (fn, ln))");
+
+        execute("UPDATE %s SET tags = tags + [ 'foo' ] WHERE fn='Tom' AND ln='Bombadil'");
+        execute("UPDATE %s SET tags = tags + [ 'bar' ] WHERE fn='Tom' AND ln='Bombadil'");
+        execute("UPDATE %s SET tags = tags + [ 'foo' ] WHERE fn='Tom' AND ln='Bombadil'");
+        execute("UPDATE %s SET tags = tags + [ 'foobar' ] WHERE fn='Tom' AND ln='Bombadil'");
+
+        assertRows(execute("SELECT tags FROM %s"),
+                   row(list("foo", "bar", "foo", "foobar")));
+
+        execute("UPDATE %s SET tags = [ 'a', 'c', 'b', 'c' ] WHERE fn='Bilbo' AND ln='Baggins'");
+        assertRows(execute("SELECT tags FROM %s WHERE fn='Bilbo' AND ln='Baggins'"),
+                   row(list("a", "c", "b", "c")));
+
+        execute("UPDATE %s SET tags = [ 'm', 'n' ] + tags WHERE fn='Bilbo' AND ln='Baggins'");
+        assertRows(execute("SELECT tags FROM %s WHERE fn='Bilbo' AND ln='Baggins'"),
+                   row(list("m", "n", "a", "c", "b", "c")));
+
+        execute("UPDATE %s SET tags[2] = 'foo', tags[4] = 'bar' WHERE fn='Bilbo' AND ln='Baggins'");
+        assertRows(execute("SELECT tags FROM %s WHERE fn='Bilbo' AND ln='Baggins'"),
+                   row(list("m", "n", "foo", "c", "bar", "c")));
+
+        execute("DELETE tags[2] FROM %s WHERE fn='Bilbo' AND ln='Baggins'");
+        assertRows(execute("SELECT tags FROM %s WHERE fn='Bilbo' AND ln='Baggins'"),
+                   row(list("m", "n", "c", "bar", "c")));
+
+        execute("UPDATE %s SET tags = tags - [ 'bar' ] WHERE fn='Bilbo' AND ln='Baggins'");
+        assertRows(execute("SELECT tags FROM %s WHERE fn='Bilbo' AND ln='Baggins'"),
+                   row(list("m", "n", "c", "c")));
+    }
+
+    /**
+     * Migrated from cql_tests.py:TestCQL.multi_collection_test()
+     */
+    @Test
+    public void testMultiCollections() throws Throwable
+    {
+        UUID id = UUID.fromString("b017f48f-ae67-11e1-9096-005056c00008");
+
+        createTable("CREATE TABLE %s (k uuid PRIMARY KEY, L list<int>, M map<text, int>, S set<int> )");
+
+        execute("UPDATE %s SET L = [1, 3, 5] WHERE k = ?", id);
+        execute("UPDATE %s SET L = L + [7, 11, 13] WHERE k = ?;", id);
+        execute("UPDATE %s SET S = {1, 3, 5} WHERE k = ?", id);
+        execute("UPDATE %s SET S = S + {7, 11, 13} WHERE k = ?", id);
+        execute("UPDATE %s SET M = {'foo': 1, 'bar' : 3} WHERE k = ?", id);
+        execute("UPDATE %s SET M = M + {'foobar' : 4} WHERE k = ?", id);
+
+        assertRows(execute("SELECT L, M, S FROM %s WHERE k = ?", id),
+                   row(list(1, 3, 5, 7, 11, 13),
+                       map("bar", 3, "foo", 1, "foobar", 4),
+                       set(1, 3, 5, 7, 11, 13)));
+    }
+
+
+    /**
+     * Migrated from cql_tests.py:TestCQL.collection_and_regular_test()
+     */
+    @Test
+    public void testCollectionAndRegularColumns() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k int PRIMARY KEY, l list<int>, c int)");
+
+        execute("INSERT INTO %s (k, l, c) VALUES(3, [0, 1, 2], 4)");
+        execute("UPDATE %s SET l[0] = 1, c = 42 WHERE k = 3");
+        assertRows(execute("SELECT l, c FROM %s WHERE k = 3"),
+                   row(list(1, 1, 2), 42));
+    }
+
+    /**
+     * Migrated from cql_tests.py:TestCQL.multi_list_set_test()
+     */
+    @Test
+    public void testMultipleLists() throws Throwable
+    {
+        createTable(" CREATE TABLE %s (k int PRIMARY KEY, l1 list<int>, l2 list<int>)");
+
+        execute("INSERT INTO %s (k, l1, l2) VALUES (0, [1, 2, 3], [4, 5, 6])");
+        execute("UPDATE %s SET l2[1] = 42, l1[1] = 24  WHERE k = 0");
+
+        assertRows(execute("SELECT l1, l2 FROM %s WHERE k = 0"),
+                   row(list(1, 24, 3), list(4, 42, 6)));
+    }
+
+    /**
+     * Test you can add columns in a table with collections (#4982 bug),
+     * migrated from cql_tests.py:TestCQL.alter_with_collections_test()
+     */
+    @Test
+    public void testAlterCollections() throws Throwable
+    {
+        createTable("CREATE TABLE %s (key int PRIMARY KEY, aset set<text>)");
+        execute("ALTER TABLE %s ADD c text");
+        execute("ALTER TABLE %s ADD alist list<text>");
+    }
+
+    /**
+     * Migrated from cql_tests.py:TestCQL.collection_compact_test()
+     */
+    @Test
+    public void testCompactCollections() throws Throwable
+    {
+        String tableName = KEYSPACE + "." + createTableName();
+        assertInvalid(String.format("CREATE TABLE %s (user ascii PRIMARY KEY, mails list < text >) WITH COMPACT STORAGE;", tableName));
+    }
+
+    /**
+     * Migrated from cql_tests.py:TestCQL.collection_function_test()
+     */
+    @Test
+    public void testFunctionsOnCollections() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k int PRIMARY KEY, l set<int>)");
+
+        assertInvalid("SELECT ttl(l) FROM %s WHERE k = 0");
+        assertInvalid("SELECT writetime(l) FROM %s WHERE k = 0");
+    }
+
+    /**
+     * Migrated from cql_tests.py:TestCQL.bug_5376()
+     */
+    @Test
+    public void testInClauseWithCollections() throws Throwable
+    {
+        createTable("CREATE TABLE %s (key text, c bigint, v text, x set < text >, PRIMARY KEY(key, c) )");
+
+        assertInvalid("select * from %s where key = 'foo' and c in (1,3,4)");
+    }
+
+    /**
+     * Test for bug #5795,
+     * migrated from cql_tests.py:TestCQL.nonpure_function_collection_test()
+     */
+    @Test
+    public void testNonPureFunctionCollection() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k int PRIMARY KEY, v list<timeuuid>)");
+
+        // we just want to make sure this doesn't throw
+        execute("INSERT INTO %s (k, v) VALUES (0, [now()])");
+    }
+
+    /**
+     * Test for 5805 bug,
+     * migrated from cql_tests.py:TestCQL.collection_flush_test()
+     */
+    @Test
+    public void testCollectionFlush() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k int PRIMARY KEY, s set<int>)");
+
+        execute("INSERT INTO %s (k, s) VALUES (1, {1})");
+        flush();
+
+        execute("INSERT INTO %s (k, s) VALUES (1, {2})");
+        flush();
+
+        assertRows(execute("SELECT * FROM %s"),
+                   row(1, set(2)));
+    }
+
+    /**
+     * Test for 6276,
+     * migrated from cql_tests.py:TestCQL.drop_and_readd_collection_test()
+     */
+    @Test
+    public void testDropAndReaddCollection() throws Throwable
+    {
+        createTable("create table %s (k int primary key, v set<text>, x int)");
+        execute("insert into %s (k, v) VALUES (0, {'fffffffff'})");
+        flush();
+        execute("alter table %s drop v");
+        assertInvalid("alter table %s add v set<int>");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01115f72/test/unit/org/apache/cassandra/cql3/validation/entities/CountersTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/CountersTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/CountersTest.java
new file mode 100644
index 0000000..e5ff251
--- /dev/null
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/CountersTest.java
@@ -0,0 +1,115 @@
+/*
+ * 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.validation.entities;
+
+import org.junit.Test;
+
+import org.apache.cassandra.cql3.CQLTester;
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.cassandra.exceptions.InvalidRequestException;
+
+public class CountersTest extends CQLTester
+{
+    /**
+     * Check for a table with counters,
+     * migrated from cql_tests.py:TestCQL.counters_test()
+     */
+    @Test
+    public void testCounters() throws Throwable
+    {
+        createTable("CREATE TABLE %s (userid int, url text, total counter, PRIMARY KEY (userid, url)) WITH COMPACT STORAGE");
+
+        execute("UPDATE %s SET total = total + 1 WHERE userid = 1 AND url = 'http://foo.com'");
+        assertRows(execute("SELECT total FROM %s WHERE userid = 1 AND url = 'http://foo.com'"),
+                   row(1L));
+
+        execute("UPDATE %s SET total = total - 4 WHERE userid = 1 AND url = 'http://foo.com'");
+        assertRows(execute("SELECT total FROM %s WHERE userid = 1 AND url = 'http://foo.com'"),
+                   row(-3L));
+
+        execute("UPDATE %s SET total = total+1 WHERE userid = 1 AND url = 'http://foo.com'");
+        assertRows(execute("SELECT total FROM %s WHERE userid = 1 AND url = 'http://foo.com'"),
+                   row(-2L));
+
+        execute("UPDATE %s SET total = total -2 WHERE userid = 1 AND url = 'http://foo.com'");
+        assertRows(execute("SELECT total FROM %s WHERE userid = 1 AND url = 'http://foo.com'"),
+                   row(-4L));
+    }
+
+    /**
+     * Test for the validation bug of #4706,
+     * migrated from cql_tests.py:TestCQL.validate_counter_regular_test()
+     */
+    @Test
+    public void testRegularCounters() throws Throwable
+    {
+        assertInvalidThrowMessage("Cannot add a non counter column",
+                                  ConfigurationException.class,
+                                  String.format("CREATE TABLE %s.%s (id bigint PRIMARY KEY, count counter, things set<text>)", KEYSPACE, createTableName()));
+    }
+
+    /**
+     * Migrated from cql_tests.py:TestCQL.collection_counter_test()
+     */
+    @Test
+    public void testCountersOnCollections() throws Throwable
+    {
+        String tableName = KEYSPACE + "." + createTableName();
+        assertInvalidThrow(InvalidRequestException.class,
+                           String.format("CREATE TABLE %s (k int PRIMARY KEY, l list<counter>)", tableName));
+
+        tableName = KEYSPACE + "." + createTableName();
+        assertInvalidThrow(InvalidRequestException.class,
+                           String.format("CREATE TABLE %s (k int PRIMARY KEY, s set<counter>)", tableName));
+
+        tableName = KEYSPACE + "." + createTableName();
+        assertInvalidThrow(InvalidRequestException.class,
+                           String.format("CREATE TABLE %s (k int PRIMARY KEY, m map<text, counter>)", tableName));
+    }
+
+    @Test
+    public void testCounterUpdatesWithUnset() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k int PRIMARY KEY, c counter)");
+
+        // set up
+        execute("UPDATE %s SET c = c + 1 WHERE k = 10");
+        assertRows(execute("SELECT c FROM %s WHERE k = 10"),
+                   row(1L)
+        );
+        // increment
+        execute("UPDATE %s SET c = c + ? WHERE k = 10", 1L);
+        assertRows(execute("SELECT c FROM %s WHERE k = 10"),
+                   row(2L)
+        );
+        execute("UPDATE %s SET c = c + ? WHERE k = 10", unset());
+        assertRows(execute("SELECT c FROM %s WHERE k = 10"),
+                   row(2L) // no change to the counter value
+        );
+        // decrement
+        execute("UPDATE %s SET c = c - ? WHERE k = 10", 1L);
+        assertRows(execute("SELECT c FROM %s WHERE k = 10"),
+                   row(1L)
+        );
+        execute("UPDATE %s SET c = c - ? WHERE k = 10", unset());
+        assertRows(execute("SELECT c FROM %s WHERE k = 10"),
+                   row(1L) // no change to the counter value
+        );
+    }
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01115f72/test/unit/org/apache/cassandra/cql3/validation/entities/DateTypeTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/DateTypeTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/DateTypeTest.java
new file mode 100644
index 0000000..7fa5e67
--- /dev/null
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/DateTypeTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.validation.entities;
+
+import org.junit.Test;
+
+import org.apache.cassandra.cql3.CQLTester;
+
+public class DateTypeTest extends CQLTester
+{
+    /**
+     * Check dates are correctly recognized and validated,
+     * migrated from cql_tests.py:TestCQL.date_test()
+     */
+    @Test
+    public void testDate() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k int PRIMARY KEY, t timestamp)");
+
+        execute("INSERT INTO %s (k, t) VALUES (0, '2011-02-03')");
+        assertInvalid("INSERT INTO %s (k, t) VALUES (0, '2011-42-42')");
+    }
+}