cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [02/10] git commit: Fix CRR/test, one more time
Date Wed, 13 Aug 2014 01:52:11 GMT
Fix CRR/test, one more time

Patch by Jeremiah Jordan, reviewed by brandonwilliams for CASSANDRA-7726


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

Branch: refs/heads/cassandra-2.1.0
Commit: 6e73a51795e1f3c87788a27e656ce326a2f75244
Parents: 67889d6
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Tue Aug 12 20:50:37 2014 -0500
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Tue Aug 12 20:50:37 2014 -0500

----------------------------------------------------------------------
 .../cassandra/hadoop/cql3/CqlRecordReader.java  |  2 +-
 .../cassandra/pig/CqlRecordReaderTest.java      | 33 +++++++++++++++++++-
 2 files changed, 33 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6e73a517/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordReader.java b/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordReader.java
index 6c75a8b..9167ac3 100644
--- a/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordReader.java
+++ b/src/java/org/apache/cassandra/hadoop/cql3/CqlRecordReader.java
@@ -546,7 +546,7 @@ public class CqlRecordReader extends RecordReader<Long, Row>
         String partitionKeyList = makeColumnList(partitionKeys);
 
         return String.format("SELECT %s FROM %s.%s WHERE token(%s)>? AND token(%s)<=?"
+ getAdditionalWhereClauses(),
-                             selectColumnList, keyspace, cfName, partitionKeyList, partitionKeyList);
+                             selectColumnList, quote(keyspace), quote(cfName), partitionKeyList,
partitionKeyList);
     }
 
     private String getAdditionalWhereClauses()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6e73a517/test/pig/org/apache/cassandra/pig/CqlRecordReaderTest.java
----------------------------------------------------------------------
diff --git a/test/pig/org/apache/cassandra/pig/CqlRecordReaderTest.java b/test/pig/org/apache/cassandra/pig/CqlRecordReaderTest.java
index fdb5107..877d30b 100644
--- a/test/pig/org/apache/cassandra/pig/CqlRecordReaderTest.java
+++ b/test/pig/org/apache/cassandra/pig/CqlRecordReaderTest.java
@@ -44,7 +44,7 @@ import org.apache.thrift.transport.TTransportException;
 public class CqlRecordReaderTest extends PigTestBase
 {
     private static String[] statements = {
-        "CREATE KEYSPACE cql3ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor'
: 1}",
+        "CREATE KEYSPACE cql3ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor'
: 1};",
         "USE cql3ks;",
 
         "CREATE TABLE cqltable (" +
@@ -56,6 +56,16 @@ public class CqlRecordReaderTest extends PigTestBase
         "data text," +
         "primary key((pk1,pk2,pk3),ck1,ck2));",
         "INSERT INTO cqltable(pk1, pk2, pk3, ck1, ck2, data) VALUES (11, 12, 13, 14, 15,
'value1');",
+
+        "CREATE TABLE \"MixedCaseCqlTable\" (" +
+        "pk1 int," +
+        "\"PK2\" int," +
+        "pk3 int," +
+        "\"CK1\" int," +
+        "ck2 int," +
+        "data text," +
+        "primary key((pk1,\"PK2\",pk3),\"CK1\",ck2));",
+        "INSERT INTO \"MixedCaseCqlTable\"(pk1, \"PK2\", pk3, \"CK1\", ck2, data) VALUES
(11, 12, 13, 14, 15, 'value1');",
     };
 
     @BeforeClass
@@ -89,6 +99,27 @@ public class CqlRecordReaderTest extends PigTestBase
     }
 
     @Test
+    public void defaultMixedCaseCqlQueryTest() throws Exception
+    {
+        String initialQuery = "rows = LOAD 'cql://cql3ks/MixedCaseCqlTable?" + defaultParameters
+ nativeParameters + "' USING CqlNativeStorage();";
+        pig.registerQuery(initialQuery);
+        Iterator<Tuple> it = pig.openIterator("rows");
+        if (it.hasNext()) {
+            Tuple t = it.next();
+            Assert.assertEquals(t.get(0), 11);
+            Assert.assertEquals(t.get(1), 12);
+            Assert.assertEquals(t.get(2), 13);
+            Assert.assertEquals(t.get(3), 14);
+            Assert.assertEquals(t.get(4), 15);
+            Assert.assertEquals(t.get(5), "value1");
+        }
+        else
+        {
+            Assert.fail("Failed to get data for query " + initialQuery);
+        }
+    }
+
+    @Test
     public void selectColumnsTest() throws Exception
     {
         String initialQuery = "rows = LOAD 'cql://cql3ks/cqltable?" + defaultParameters +
nativeParameters + "&columns=ck1%2Cck2%2Cdata' USING CqlNativeStorage();";


Mime
View raw message