You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ee...@apache.org on 2010/11/12 20:32:25 UTC

svn commit: r1034531 - /cassandra/trunk/doc/cql/CQL.textile

Author: eevans
Date: Fri Nov 12 19:32:25 2010
New Revision: 1034531

URL: http://svn.apache.org/viewvc?rev=1034531&view=rev
Log:
CASSANDRA-1704. doc update for proposed SELECT

Patch by eevans

Modified:
    cassandra/trunk/doc/cql/CQL.textile

Modified: cassandra/trunk/doc/cql/CQL.textile
URL: http://svn.apache.org/viewvc/cassandra/trunk/doc/cql/CQL.textile?rev=1034531&r1=1034530&r2=1034531&view=diff
==============================================================================
--- cassandra/trunk/doc/cql/CQL.textile (original)
+++ cassandra/trunk/doc/cql/CQL.textile Fri Nov 12 19:32:25 2010
@@ -1,4 +1,4 @@
-h1. Cassandra Query Language (CQL) v0.99.0
+h1. Cassandra Query Language (CQL) v0.99.1
 
 h2. Table of Contents
 
@@ -18,54 +18,55 @@ h2. SELECT
 __Synopsis:__
 
 bc. 
-SELECT [FROM] <COLUMN FAMILY> [USING <CONSISTENCY>]
-        WHERE <EXRESSION> [ROWLIMIT N] [COLLIMIT N] [ASC | DESC];
+SELECT [FIRST N] [REVERSED] <SELECT EXPR> FROM <COLUMN FAMILY> [USING <CONSISTENCY>]
+        [WHERE <CLAUSE>] [LIMIT N];
 
 A @SELECT@ is used to read one or more records from a Cassandra column family. It returns a result-set of rows, where each row consists of a key and a collection of columns corresponding to the query.
 
-h3. Column Family
+h3. Specifying Columns
 
 bc. 
-SELECT [FROM] <COLUMN FAMILY> ...
+SELECT [FIRST N] [REVERSED] name1, name2, name3 FROM ...
+SELECT [FIRST N] [REVERSED] name1..nameN FROM ...
 
-Statements begin with the @SELECT@ keyword followed by a Cassandra column family name. The keyword @FROM@ can be used as a delimiter to improve readability, but is not required.
+The SELECT expression determines which columns will appear in the results and takes the form of either a comma separated list of names, or a range. The range notation consists of a start and end column name separated by two periods (@..@). The set of columns returned for a range is start and end inclusive.
 
-h3. Consistency Level
+The @FIRST@ option accepts an integer argument and can be used to apply a limit to the number of columns returned per row.  When this limit is left unset it defaults to 10,000 columns.
 
-bc. 
-SELECT ... [USING <CONSISTENCY>] ...
+The @REVERSED@ option causes the sort order of the results to be reversed.
 
-Following the column family identifier is an optional "consistency level specification":#consistency.
+It is worth noting that unlike the projection in a SQL SELECT, there is no guarantee that the results will contain all of the columns specified. This is because Cassandra is schema-less and there are no guarantees that a given column exists.
 
-h3. Expressions
+h3. Column Family
 
 bc. 
-SELECT ... <EXPRESSION>
-SELECT ... [[KEY | COL] [> | >= | = | < | <=] TERM] [[AND ...] ...]
-
-The expression portion of a CQL @SELECT@ statement consists of one or more relations delimited by the @AND@ keyword.  Relations are defined as one of either the @KEY@ or @COLUMN@ keywords, a relational operator (@>@, @>=@, @=@, @<@, @<=@), and a "term":#terms.
-
-_NOTE: The keyword @COLUMN@ can be abbreviated as @COL@._
+SELECT ... FROM <COLUMN FAMILY> ...
 
-_NOTE: Key and column ranges are always inclusive so the semantics of @>=@ and @>@, and @<=@ and @<@ are identical.  This is subject to change._
+The @FROM@ clause is used to specify the Cassandra column family applicable to a @SELECT@ query.
 
-h3. Limits
+h3. Consistency Level
 
 bc. 
-SELECT ... <EXPRESSION> [ROWLIMIT N | COLLIMIT N] ...
+SELECT ... [USING <CONSISTENCY>] ...
 
-Limiting the number of row and/or column results can be achieved by including one or both of the optional @ROWLIMIT@ and @COLLIMIT@ clauses after a @SELECT@ expression. Both @ROWLIMIT@ and @COLLIMIT@ default to 10,000 when left unset.
+Following the column family clause is an optional "consistency level specification":#consistency.
 
-h3. Ordering
+h3. Filtering rows
 
 bc. 
-SELECT ... [[ASC | ASCENDING] | [DESC | DESCENDING]]
+SELECT ... WHERE KEY = keyname AND name1 = value1
+SELECT ... WHERE KEY >= startkey and KEY =< endkey AND name1 = value1
+
+The WHERE clause provides for filtering the rows that appear in results.  The clause can filter on a key name, or range of keys, and in the case of indexed columns, on column values.  Key filters are specified using the @KEY@ keyword, a relational operator, (one of @=@, @>@, @>=@, @<@, and @<=@), and a term value.  When terms appear on both sides of a relational operator it is assumed the filter applies to an indexed column. With column index filters, the term on the left of the operator is the name, the term on the right is the value to filter __on__.
 
-By default, results are returned in the order determined by the column family comparator, _this is always considered ascending order_.  Reversing this sort order is possible by supplying the @DESCENDING@ clause in @SELECT@ statements.
+__Note: The greater-than and less-than operators (@>@ and @<@) result in key ranges that are inclusive of the terms. There is no supported notion of "strictly" greater-than or less-than; these operators are merely supported as aliases to @>=@ and @<=@.__  
 
-The @ASCENDING@ keyword is also included, both for completeness sake, and to improve statement readability if desired.  It has no effect otherwise.
+h3. Limits
+
+bc. 
+SELECT ... WHERE <CLAUSE> [LIMIT N] ...
 
-_NOTE: The keywords @ASC@ and @DESC@ are valid abbreviations for @ASCENDING@ and @DESCENDING@ respectively._
+Limiting the number of rows returned can be achieved by adding the @LIMIT@ option to a @SELECT@ expression. @LIMIT@ defaults to 10,000 when left unset.
 
 h2. UPDATE