cqlsh: sort columns so COPY TO -> FROM works. Patch by paul cannon, reviewed by brandonwilliams for CASSANDRA-4594
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/1e6cc9ae Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/1e6cc9ae Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/1e6cc9ae Branch: refs/heads/trunk Commit: 1e6cc9aebc6040e50cca411813fe02afc221a117 Parents: 9eba7ab Author: Brandon Williams <brandonwilli...@apache.org> Authored: Thu Sep 13 13:34:53 2012 -0500 Committer: Brandon Williams <brandonwilli...@apache.org> Committed: Thu Sep 13 13:53:38 2012 -0500 ---------------------------------------------------------------------- bin/cqlsh | 7 +++---- pylib/cqlshlib/cql3handling.py | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/1e6cc9ae/bin/cqlsh ---------------------------------------------------------------------- diff --git a/bin/cqlsh b/bin/cqlsh index 8d98c28..65f1003 100755 --- a/bin/cqlsh +++ b/bin/cqlsh @@ -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 http://git-wip-us.apache.org/repos/asf/cassandra/blob/1e6cc9ae/pylib/cqlshlib/cql3handling.py ---------------------------------------------------------------------- diff --git a/pylib/cqlshlib/cql3handling.py b/pylib/cqlshlib/cql3handling.py index 5099322..a081741 100644 --- a/pylib/cqlshlib/cql3handling.py +++ b/pylib/cqlshlib/cql3handling.py @@ -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):