Permalink
Browse files

cqlsh: tab-complete key alias for ALTER CF ALTER

patch by thepaul; reviewed by slebresne for CASSANDRA-3873
  • Loading branch information...
1 parent 5888fcd commit d64b9fff57aac10a0078efd5121e84a11e808075 @pcmanus pcmanus committed Feb 24, 2012
Showing with 11 additions and 8 deletions.
  1. +6 −6 bin/cqlsh
  2. +1 −1 doc/cql/CQL.textile
  3. +4 −1 pylib/cqlshlib/cqlhandling.py
View
@@ -1901,12 +1901,12 @@ class Shell(cmd.Cmd):
ALTER COLUMNFAMILY addamsFamily ALTER lastKnownLocation TYPE uuid;
ALTER COLUMNFAMILY ... ALTER changes the expected storage type for a
- column. The column must already have a type in the column family
- metadata. The column may or may not already exist in current rows-- but
- be aware that no validation of existing data is done. The bytes stored
- in values for that column will remain unchanged, and if existing data
- is not deserializable according to the new type, this may cause your
- CQL driver or interface to report errors.
+ column. The column must either be the key alias or already have a type
+ in the column family metadata. The column may or may not already exist
+ in current rows-- but be aware that no validation of existing data is
+ done. The bytes stored in values for that column will remain unchanged,
+ and if existing data is not deserializable according to the new type,
+ this may cause your CQL driver or interface to report errors.
"""
def help_alter_add(self):
View
@@ -634,7 +634,7 @@ h3. Changing the type of a typed column
bc(sample).
ALTER COLUMNFAMILY addamsFamily ALTER lastKnownLocation TYPE uuid;
-@ALTER COLUMNFAMILY ... ALTER@ changes the expected storage type for a column. The column must already have a type in the column family metadata. The column may or may not already exist in current rows-- but be aware that no validation of existing data is done. The bytes stored in values for that column will remain unchanged, and if existing data is not deserializable according to the new type, this may cause your CQL driver or interface to report errors.
+@ALTER COLUMNFAMILY ... ALTER@ changes the expected storage type for a column. The column must either be the key alias or already have a type in the column family metadata. The column may or may not already exist in current rows-- but be aware that no validation of existing data is done. The bytes stored in values for that column will remain unchanged, and if existing data is not deserializable according to the new type, this may cause your CQL driver or interface to report errors.
h3. Adding a typed column
@@ -726,7 +726,10 @@ def alter_table_cf_completer(ctxt, cass):
@completer_for('alterInstructions', 'existcol')
def alter_table_col_completer(ctxt, cass):
cfdef = cass.get_columnfamily(cql_dequote(ctxt.get_binding('cf')))
- return map(maybe_cql_escape, [md.name for md in cfdef.column_metadata])
+ cols = [md.name for md in cfdef.column_metadata]
+ if cfdef.key_alias is not None:
+ cols.append(cfdef.key_alias)
+ return map(maybe_cql_escape, cols)
explain_completion('alterInstructions', 'newcol', '<new_column_name>')

0 comments on commit d64b9ff

Please sign in to comment.