Merge branch 'cassandra-1.2' into trunk
Conflicts:
bin/cqlsh
doc/cql3/CQL.textile
src/java/org/apache/cassandra/cql3/QueryProcessor.java
src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/7edd0e0c
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/7edd0e0c
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/7edd0e0c
Branch: refs/heads/trunk
Commit: 7edd0e0c7e05e87a1a48b81a6add08a6e65d73f1
Parents: 26018be 2397bc8
Author: Aleksey Yeschenko <[email protected]>
Authored: Tue Jun 18 17:29:23 2013 +0300
Committer: Aleksey Yeschenko <[email protected]>
Committed: Tue Jun 18 17:29:23 2013 +0300
----------------------------------------------------------------------
CHANGES.txt | 1 +
NEWS.txt | 3 +
doc/cql3/CQL.textile | 8 ++-
pylib/cqlshlib/cql3handling.py | 2 +-
src/java/org/apache/cassandra/cql3/Cql.g | 8 +--
.../apache/cassandra/cql3/IndexPropDefs.java | 68 --------------------
.../cql3/statements/CreateIndexStatement.java | 30 ++++-----
7 files changed, 26 insertions(+), 94 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/7edd0e0c/CHANGES.txt
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/7edd0e0c/NEWS.txt
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/7edd0e0c/doc/cql3/CQL.textile
----------------------------------------------------------------------
diff --cc doc/cql3/CQL.textile
index 169cf2b,5fa36ab..1648cc8
--- a/doc/cql3/CQL.textile
+++ b/doc/cql3/CQL.textile
@@@ -1056,11 -1048,10 +1056,15 @@@ h2(#changes). Change
The following describes the addition/changes brought for each version of CQL.
+h3. 3.1.0
+
+* "ALTER TABLE":#alterTableStmt @DROP@ option has been reenabled for CQL3
tables and has new semantics now: the space formerly used by dropped columns
will now be eventually reclaimed (post-compaction). You should not readd
previously dropped columns unless you use timestamps with microsecond precision
(see "CASSANDRA-3919":https://issues.apache.org/jira/browse/CASSANDRA-3919 for
more details).
+* SELECT statement now supports aliases in select clause. Aliases in WHERE
and ORDER BY clauses are not supported. See the "section on select"#selectStmt
for details.
+
+ h3. 3.0.4
+
+ * Updated the syntax for custom "secondary indexes":#createIndexStmt.
+
h3. 3.0.3
* Support for custom "secondary indexes":#createIndexStmt has been added.
http://git-wip-us.apache.org/repos/asf/cassandra/blob/7edd0e0c/pylib/cqlshlib/cql3handling.py
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/7edd0e0c/src/java/org/apache/cassandra/cql3/Cql.g
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/7edd0e0c/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
----------------------------------------------------------------------
diff --cc
src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
index 4b61ab3,b79a255..12f762f
--- a/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
@@@ -26,8 -28,11 +26,9 @@@ import org.apache.cassandra.auth.Permis
import org.apache.cassandra.config.CFMetaData;
import org.apache.cassandra.config.ColumnDefinition;
import org.apache.cassandra.config.Schema;
+ import org.apache.cassandra.db.index.SecondaryIndex;
import org.apache.cassandra.exceptions.*;
import org.apache.cassandra.cql3.*;
-import org.apache.cassandra.db.index.composites.CompositesIndex;
-import org.apache.cassandra.db.marshal.CompositeType;
import org.apache.cassandra.service.ClientState;
import org.apache.cassandra.service.MigrationManager;
import org.apache.cassandra.thrift.IndexType;
@@@ -62,25 -67,32 +63,29 @@@ public class CreateIndexStatement exten
public void validate(ClientState state) throws RequestValidationException
{
CFMetaData cfm = ThriftValidation.validateColumnFamily(keyspace(),
columnFamily());
- CFDefinition.Name name = cfm.getCfDef().get(columnName);
+ ColumnDefinition cd = cfm.getColumnDefinition(columnName.key);
- if (name == null)
+ if (cd == null)
throw new InvalidRequestException("No column definition found for
column " + columnName);
- switch (name.kind)
- {
- case KEY_ALIAS:
- case COLUMN_ALIAS:
- throw new InvalidRequestException(String.format("Cannot
create index on PRIMARY KEY part %s", columnName));
- case VALUE_ALIAS:
- throw new InvalidRequestException(String.format("Cannot
create index on column %s of compact CF", columnName));
- case COLUMN_METADATA:
- ColumnDefinition cd = cfm.getColumnDefinition(columnName.key);
- if (cd.getIndexType() != null)
- throw new InvalidRequestException("Index already exists");
- if (isCustom && indexClass == null)
- throw new InvalidRequestException("CUSTOM index requires
specifiying the index class");
- if (!isCustom && indexClass != null)
- throw new InvalidRequestException("Cannot specify index
class for a non-CUSTOM index");
- if (cd.getValidator().isCollection() && !isCustom)
- throw new InvalidRequestException("Indexes on collections
are no yet supported");
- break;
- default:
- throw new AssertionError();
- }
+ if (cd.getIndexType() != null)
+ throw new InvalidRequestException("Index already exists");
+
++ if (isCustom && indexClass == null)
++ throw new InvalidRequestException("CUSTOM index requires
specifiying the index class");
++
++ if (!isCustom && indexClass != null)
++ throw new InvalidRequestException("Cannot specify index class for
a non-CUSTOM index");
++
+ // TODO: we could lift that limitation
+ if (cfm.getCfDef().isCompact && cd.type !=
ColumnDefinition.Type.REGULAR)
+ throw new InvalidRequestException(String.format("Secondary index
on %s column %s is not yet supported for compact table", cd.type, columnName));
+
+ if (cd.getValidator().isCollection() && !isCustom)
+ throw new InvalidRequestException("Indexes on collections are no
yet supported");
+
+ if (cd.type == ColumnDefinition.Type.PARTITION_KEY &&
(cd.componentIndex == null || cd.componentIndex == 0))
+ throw new InvalidRequestException(String.format("Cannot add
secondary index to already primarily indexed column %s", columnName));
-
- props.validate(isCustom);
}
public void announceMigration() throws InvalidRequestException,
ConfigurationException
@@@ -90,24 -102,21 +95,11 @@@
ColumnDefinition cd = cfm.getColumnDefinition(columnName.key);
if (isCustom)
-- {
- try
- {
- cd.setIndexType(IndexType.CUSTOM, props.getOptions());
- }
- catch (SyntaxException e)
- {
- throw new AssertionError(); // can't happen after validation.
- }
- }
+ cd.setIndexType(IndexType.CUSTOM,
Collections.singletonMap(SecondaryIndex.CUSTOM_INDEX_OPTION_NAME, indexClass));
- }
- else if (cfDef.isComposite)
- {
- CompositeType composite = (CompositeType)cfm.comparator;
- Map<String, String> opts = new HashMap<String, String>();
- opts.put(CompositesIndex.PREFIX_SIZE_OPTION,
String.valueOf(composite.types.size() - (cfDef.hasCollections ? 2 : 1)));
- cd.setIndexType(IndexType.COMPOSITES, opts);
- }
+ else if (cfm.getCfDef().isComposite)
- {
+ cd.setIndexType(IndexType.COMPOSITES, Collections.<String,
String>emptyMap());
- }
else
-- {
cd.setIndexType(IndexType.KEYS, Collections.<String,
String>emptyMap());
-- }
cd.setIndexName(indexName);
cfm.addDefaultIndexNames();