Repository: cassandra
Updated Branches:
  refs/heads/trunk f2673082c -> 5e6eb0e72


Fix CREATE TABLE for CQL2

patch by Aleksey Yeschenko; reviewed by Sam Tunnicliffe for
CASSANDRA-8144


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

Branch: refs/heads/trunk
Commit: 94fea8df626e13e65615b065b78d5165a1da08be
Parents: 3261d5e
Author: Aleksey Yeschenko <alek...@apache.org>
Authored: Wed Oct 22 17:46:23 2014 +0300
Committer: Aleksey Yeschenko <alek...@apache.org>
Committed: Wed Oct 22 17:46:23 2014 +0300

----------------------------------------------------------------------
 CHANGES.txt                                     |  4 +++
 .../cql/CreateColumnFamilyStatement.java        | 26 +++++++++-----------
 2 files changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/94fea8df/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 96a5e23..5882080 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,7 @@
+2.1.2
+ * Fix CREATE TABLE for CQL2 (CASSANDRA-8144)
+
+
 2.1.1
  * Dont notify when replacing tmplink files (CASSANDRA-8157)
  * Fix validation with multiple CONTAINS clause (CASSANDRA-8131)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/94fea8df/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java 
b/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java
index 4cb9eba..d3bafe6 100644
--- a/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java
+++ b/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java
@@ -27,7 +27,7 @@ import java.util.Set;
 import org.apache.cassandra.cache.CachingOptions;
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.ColumnDefinition;
-import org.apache.cassandra.db.composites.SimpleDenseCellNameType;
+import org.apache.cassandra.db.composites.CellNames;
 import org.apache.cassandra.db.ColumnFamilyType;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.db.marshal.TypeParser;
@@ -168,15 +168,13 @@ public class CreateColumnFamilyStatement
     {
         validate(variables);
 
-        CFMetaData newCFMD;
         try
         {
-            AbstractType<?> comparator = cfProps.getComparator();
-
-            newCFMD = new CFMetaData(keyspace,
-                                     name,
-                                     ColumnFamilyType.Standard,
-                                     new SimpleDenseCellNameType(comparator));
+            boolean isDense = columns.isEmpty();
+            CFMetaData newCFMD = new CFMetaData(keyspace,
+                                                name,
+                                                ColumnFamilyType.Standard,
+                                                
CellNames.fromAbstractType(cfProps.getComparator(), isDense));
 
             if (CFMetaData.DEFAULT_COMPRESSOR != null && 
cfProps.compressionParameters.isEmpty())
                 
cfProps.compressionParameters.put(CompressionParameters.SSTABLE_COMPRESSION, 
CFMetaData.DEFAULT_COMPRESSOR);
@@ -185,7 +183,8 @@ public class CreateColumnFamilyStatement
             if (minCompactionThreshold <= 0 || maxCompactionThreshold <= 0)
                 throw new ConfigurationException("Disabling compaction by 
setting compaction thresholds to 0 has been deprecated, set the compaction 
option 'enabled' to false instead.");
 
-            newCFMD.addAllColumnDefinitions(getColumns(newCFMD))
+            newCFMD.isDense(isDense)
+                   .addAllColumnDefinitions(getColumns(newCFMD))
                    .comment(cfProps.getProperty(CFPropDefs.KW_COMMENT))
                    
.readRepairChance(getPropertyDouble(CFPropDefs.KW_READREPAIRCHANCE, 
CFMetaData.DEFAULT_READ_REPAIR_CHANCE))
                    
.dcLocalReadRepairChance(getPropertyDouble(CFPropDefs.KW_DCLOCALREADREPAIRCHANCE,
 CFMetaData.DEFAULT_DCLOCAL_READ_REPAIR_CHANCE))
@@ -206,16 +205,13 @@ public class CreateColumnFamilyStatement
             // CQL2 can have null keyAliases
             if (keyAlias != null)
                 
newCFMD.addColumnDefinition(ColumnDefinition.partitionKeyDef(newCFMD, keyAlias, 
newCFMD.getKeyValidator(), null));
+
+            return newCFMD.rebuild();
         }
-        catch (ConfigurationException e)
-        {
-            throw new InvalidRequestException(e.toString());
-        }
-        catch (SyntaxException e)
+        catch (ConfigurationException | SyntaxException e)
         {
             throw new InvalidRequestException(e.toString());
         }
-        return newCFMD;
     }
 
     private String getPropertyString(String key, String defaultValue)

Reply via email to