Repository: cassandra Updated Branches: refs/heads/cassandra-2.0 0ff7f9969 -> b07f4b8c7
Handle static columns in cqlsh. Patch by Mikhail Stepura for CASSANDRA-6703; reviewed by Aleksey Yeschenko Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b07f4b8c Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b07f4b8c Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b07f4b8c Branch: refs/heads/cassandra-2.0 Commit: b07f4b8c775efeb96d6688aa0723285ee7b3c9e3 Parents: 0ff7f99 Author: Mikhail Stepura <[email protected]> Authored: Thu Feb 27 15:53:24 2014 -0800 Committer: Mikhail Stepura <[email protected]> Committed: Tue Mar 4 11:47:58 2014 -0800 ---------------------------------------------------------------------- bin/cqlsh | 5 ++++- pylib/cqlshlib/cql3handling.py | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/b07f4b8c/bin/cqlsh ---------------------------------------------------------------------- diff --git a/bin/cqlsh b/bin/cqlsh index 1b97783..1f9425c 100755 --- a/bin/cqlsh +++ b/bin/cqlsh @@ -1109,7 +1109,10 @@ class Shell(cmd.Cmd): if issubclass(coltype, ReversedType): coltype = coltype.subtypes[0] - out.write(" %s %s,\n" % (colname, coltype.cql_parameterized_type())) + out.write(" %s %s" % (colname, coltype.cql_parameterized_type())) + if col.is_static(): + out.write(" static") + out.write(",\n") out.write(" PRIMARY KEY (") partkeynames = self.cql_protect_names(layout.partition_key_columns) http://git-wip-us.apache.org/repos/asf/cassandra/blob/b07f4b8c/pylib/cqlshlib/cql3handling.py ---------------------------------------------------------------------- diff --git a/pylib/cqlshlib/cql3handling.py b/pylib/cqlshlib/cql3handling.py index 5fe96bb..4791a15 100644 --- a/pylib/cqlshlib/cql3handling.py +++ b/pylib/cqlshlib/cql3handling.py @@ -852,8 +852,8 @@ syntax_rules += r''' ; <compositeKeyCfSpec> ::= [newcolname]=<cident> <simpleStorageType> - "," [newcolname]=<cident> <storageType> - ( "," [newcolname]=<cident> <storageType> )* + "," [newcolname]=<cident> <storageType> ( "static" )? + ( "," [newcolname]=<cident> <storageType> ( "static" )? )* "," "PRIMARY" k="KEY" p="(" ( partkey=<pkDef> | [pkey]=<cident> ) ( c="," [pkey]=<cident> )* ")" ; @@ -960,7 +960,7 @@ syntax_rules += r''' <alterInstructions> ; <alterInstructions> ::= "ALTER" existcol=<cident> "TYPE" <storageType> - | "ADD" newcol=<cident> <storageType> + | "ADD" newcol=<cident> <storageType> ("static")? | "DROP" existcol=<cident> | "WITH" <cfamProperty> ( "AND" <cfamProperty> )* | "RENAME" existcol=<cident> "TO" newcol=<cident> @@ -1079,6 +1079,9 @@ class CqlColumnDef: c.index_options = json.loads(layout[u'index_options']) return c + def is_static(self): + return self.component_type == 'static' + def __str__(self): indexstr = ' (index %s)' % self.index_name if self.index_name is not None else '' return '<CqlColumnDef %r %r%s>' % (self.name, self.cqltype, indexstr)
