cqlsh: sort columns so COPY TO -> FROM works.

Patch by paul cannon, reviewed by brandonwilliams for CASSANDRA-4594
This commit is contained in:
Brandon Williams 2012-09-13 13:34:53 -05:00
parent 9eba7ab3ba
commit 1e6cc9aebc
2 changed files with 4 additions and 4 deletions

View File

@ -753,7 +753,7 @@ class Shell(cmd.Cmd):
key_alias = cfdef.key_alias
if key_alias is None:
key_alias = 'KEY'
return [key_alias] + [cm.name for cm in cfdef.column_metadata]
return [key_alias] + sorted([cm.name for cm in cfdef.column_metadata])
# ===== thrift-dependent parts =====
@ -1625,9 +1625,8 @@ class Shell(cmd.Cmd):
def prep_export_dump(self, ks, cf, columns):
if columns is None:
columnlist = '*'
else:
columnlist = ', '.join(map(self.cql_protect_name, columns))
columns = self.get_column_names(ks, cf)
columnlist = ', '.join(map(self.cql_protect_name, columns))
# this limit is pretty awful. would be better to use row-key-paging, so
# that the dump could be pretty easily aborted if necessary, but that
# can be kind of tricky with cql3. Punt for now, until the real cursor

View File

@ -811,6 +811,7 @@ class CqlTableDef:
subtypes = subtypes[:len(self.key_components)]
keycols = map(self.column_class, self.key_components, subtypes)
normal_cols = map(self.column_class.from_layout, self.coldefs)
normal_cols.sort(key=lambda c: c.name)
self.columns = keycols + value_cols + normal_cols
def is_counter_col(self, colname):