cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eev...@apache.org
Subject svn commit: r1034537 - in /cassandra/trunk: src/java/org/apache/cassandra/cql/QueryProcessor.java src/java/org/apache/cassandra/cql/SelectStatement.java test/system/test_cql.py
Date Fri, 12 Nov 2010 19:33:00 GMT
Author: eevans
Date: Fri Nov 12 19:33:00 2010
New Revision: 1034537

URL: http://svn.apache.org/viewvc?rev=1034537&view=rev
Log:
support empty/unset where clause

Patch by eevans

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java
    cassandra/trunk/src/java/org/apache/cassandra/cql/SelectStatement.java
    cassandra/trunk/test/system/test_cql.py

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java?rev=1034537&r1=1034536&r2=1034537&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java Fri Nov 12 19:33:00
2010
@@ -136,11 +136,10 @@ public class QueryProcessor
     {
         List<org.apache.cassandra.db.Row> rows = null;
         
-        // FIXME: ranges can be open-ended, but a start must exist.  Assert so here.
-        
+        ByteBuffer startKey = (select.getKeyStart() != null) ? select.getKeyStart().getByteBuffer()
: (new Term()).getByteBuffer();
+        ByteBuffer finishKey = (select.getKeyFinish() != null) ? select.getKeyFinish().getByteBuffer()
: (new Term()).getByteBuffer();
         IPartitioner<?> p = StorageService.getPartitioner();
-        AbstractBounds bounds = new Bounds(p.getToken(select.getKeyStart().getByteBuffer()),
-                                           p.getToken(select.getKeyFinish().getByteBuffer()));
+        AbstractBounds bounds = new Bounds(p.getToken(startKey), p.getToken(finishKey));
         
         // XXX: Our use of Thrift structs internally makes me Sad. :(
         SlicePredicate thriftSlicePredicate = slicePredicateFromSelect(select);

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/SelectStatement.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/SelectStatement.java?rev=1034537&r1=1034536&r2=1034537&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/SelectStatement.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/SelectStatement.java Fri Nov 12 19:33:00
2010
@@ -43,7 +43,7 @@ public class SelectStatement
         this.expression = expression;
         this.columnFamily = columnFamily;
         this.cLevel = cLevel;
-        this.clause = clause;
+        this.clause = (clause != null) ? clause : new WhereClause();
         this.numRecords = numRecords;
     }
     

Modified: cassandra/trunk/test/system/test_cql.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/system/test_cql.py?rev=1034537&r1=1034536&r2=1034537&view=diff
==============================================================================
--- cassandra/trunk/test/system/test_cql.py (original)
+++ cassandra/trunk/test/system/test_cql.py Fri Nov 12 19:33:00 2010
@@ -141,3 +141,13 @@ class TestCql(AvroTester):
         """)
         assert len(r) == 1
         assert r[0]['key'] == "dozer"
+
+    def test_no_where_clause(self):
+        "empty where clause (range query w/o start key)"
+        conn = init()
+        r = conn.execute('SELECT "col" FROM Standard1 LIMIT 3')
+        assert len(r) == 3
+        assert r[0]['key'] == "ka"
+        assert r[1]['key'] == "kb"
+        assert r[2]['key'] == "kc"
+



Mime
View raw message