cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcken...@apache.org
Subject [1/3] cassandra git commit: Allow specification of 'time' column value as number in CQL query
Date Fri, 17 Jun 2016 17:45:20 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 dbc40b1ed -> 863dbc787
  refs/heads/trunk 6c9c09118 -> c35e55de4


Allow specification of 'time' column value as number in CQL query

Patch by Alex Petrov; reviewed by jmckenzie for CASSANDRA-11798


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

Branch: refs/heads/cassandra-3.0
Commit: 863dbc78777101eab08f23877a4d9ffc92ffb6b4
Parents: dbc40b1
Author: Alex Petrov <oleksandr.petrov@gmail.com>
Authored: Wed May 25 16:19:47 2016 +0200
Committer: Josh McKenzie <jmckenzie@apache.org>
Committed: Fri Jun 17 13:42:39 2016 -0400

----------------------------------------------------------------------
 .../org/apache/cassandra/cql3/Constants.java    |  1 +
 .../cassandra/db/marshal/TimeTypeTest.java      | 27 ++++++++++++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/863dbc78/src/java/org/apache/cassandra/cql3/Constants.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Constants.java b/src/java/org/apache/cassandra/cql3/Constants.java
index 4982c49..a2bacdf 100644
--- a/src/java/org/apache/cassandra/cql3/Constants.java
+++ b/src/java/org/apache/cassandra/cql3/Constants.java
@@ -196,6 +196,7 @@ public abstract class Constants
                         case FLOAT:
                         case INT:
                         case SMALLINT:
+                        case TIME:
                         case TIMESTAMP:
                         case TINYINT:
                         case VARINT:

http://git-wip-us.apache.org/repos/asf/cassandra/blob/863dbc78/test/unit/org/apache/cassandra/db/marshal/TimeTypeTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/marshal/TimeTypeTest.java b/test/unit/org/apache/cassandra/db/marshal/TimeTypeTest.java
index 699c805..d61d2c6 100644
--- a/test/unit/org/apache/cassandra/db/marshal/TimeTypeTest.java
+++ b/test/unit/org/apache/cassandra/db/marshal/TimeTypeTest.java
@@ -23,11 +23,14 @@ import java.nio.ByteBuffer;
 import java.util.concurrent.TimeUnit;
 
 import org.junit.Test;
+
+import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.serializers.TimeSerializer;
 
-public class TimeTypeTest
+public class TimeTypeTest extends CQLTester
 {
-    @Test public void TestComparison()
+    @Test
+    public void testComparison()
     {
         Long t1 = TimeSerializer.timeStringToLong("01:00:00.123456789");
         Long t2 = new Long((1L * 60L * 60L * 1000L * 1000L * 1000L) + 123456789);
@@ -58,4 +61,24 @@ public class TimeTypeTest
         b2 = TimeSerializer.instance.serialize(0L);
         assert TimeType.instance.compare(b1, b2) > 0 : "Failed > comparison against
max range.";
     }
+
+    /**
+     * Check that time is correctly recognized and validated
+     */
+    @Test
+    public void testTime() throws Throwable
+    {
+        createTable("CREATE TABLE %s (id int, cl int, ts time, PRIMARY KEY(id, cl));");
+
+        execute("INSERT into %s (id, cl, ts) values (1, 1, 42000000000);");
+        execute("INSERT into %s (id, cl, ts) values (1, 2, '42000000000');");
+        execute("INSERT into %s (id, cl, ts) values (1, 3, '00:00:42.000000000');");
+        execute("INSERT into %s (id, cl, ts) values (1, 4, ?);", 42000000000L);
+
+        assertRows(execute("SELECT * FROM %s"),
+                   row(1, 1, 42000000000L),
+                   row(1, 2, 42000000000L),
+                   row(1, 3, 42000000000L),
+                   row(1, 4, 42000000000L));
+    }
 }


Mime
View raw message