You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ty...@apache.org on 2014/08/21 00:51:52 UTC
[1/2] git commit: cqlsh: preserve original result column names
Repository: cassandra
Updated Branches:
refs/heads/cassandra-2.1 6e0512576 -> 1aea6d591
cqlsh: preserve original result column names
Patch by Tyler Hobbs; reviewed by Aleksey Yeschenko for CASSANDRA-7806
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/c4191ed1
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/c4191ed1
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/c4191ed1
Branch: refs/heads/cassandra-2.1
Commit: c4191ed1c9a3f623b2f37a5aab51a76174ee2eeb
Parents: 58554de
Author: Tyler Hobbs <ty...@datastax.com>
Authored: Wed Aug 20 17:46:41 2014 -0500
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Wed Aug 20 17:46:41 2014 -0500
----------------------------------------------------------------------
CHANGES.txt | 2 ++
bin/cqlsh | 15 ++++++++-------
pylib/cqlshlib/cql3handling.py | 8 ++++----
3 files changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c4191ed1/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 2664f0f..92a177d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
2.1.0
+ * (cqlsh) Fix column name formatting for functions, CAS operations,
+ and UDT field selections (CASSANDRA-7806)
* (cqlsh) Fix COPY FROM handling of null/empty primary key
values (CASSANDRA-7792)
* Fix ordering of static cells (CASSANDRA-7763)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c4191ed1/bin/cqlsh
----------------------------------------------------------------------
diff --git a/bin/cqlsh b/bin/cqlsh
index 4c90f2d..686e07b 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -107,7 +107,7 @@ except ImportError, e:
'Error: %s\n' % (sys.executable, sys.path, e))
from cassandra.cluster import Cluster
-from cassandra.query import SimpleStatement
+from cassandra.query import SimpleStatement, ordered_dict_factory
from cassandra.policies import WhiteListRoundRobinPolicy
from cassandra.metadata import protect_name, protect_names, protect_value
from cassandra.auth import PlainTextAuthProvider
@@ -521,6 +521,7 @@ class Shell(cmd.Cmd):
self.session = self.conn.connect(keyspace)
else:
self.session = self.conn.connect()
+ self.session.row_factory = ordered_dict_factory
self.get_connection_versions()
self.current_keyspace = keyspace
@@ -612,9 +613,9 @@ class Shell(cmd.Cmd):
def get_connection_versions(self):
result, = self.session.execute("select * from system.local where key = 'local'")
vers = {
- 'build': result.release_version,
- 'protocol': result.native_protocol_version,
- 'cql': result.cql_version,
+ 'build': result['release_version'],
+ 'protocol': result['native_protocol_version'],
+ 'cql': result['cql_version'],
}
self.connection_versions = vers
self.cass_ver_tuple = tuple(map(int, vers['build'].split('-', 1)[0].split('.')[:3]))
@@ -952,9 +953,9 @@ class Shell(cmd.Cmd):
def print_static_result(self, rows):
if not rows:
return
- colnames = rows[0]._fields
+ colnames = rows[0].keys()
formatted_names = [self.myformat_colname(name) for name in colnames]
- formatted_values = [map(self.myformat_value, row) for row in rows]
+ formatted_values = [map(self.myformat_value, row.values()) for row in rows]
if self.expand_enabled:
self.print_formatted_result_vertically(formatted_names, formatted_values)
else:
@@ -1423,7 +1424,7 @@ class Shell(cmd.Cmd):
format_value(v, output_encoding=encoding, nullval=nullval,
time_format=self.display_time_format,
float_precision=self.display_float_precision).strval
- writer.writerow(map(fmt, row))
+ writer.writerow(map(fmt, row.values()))
rows += 1
finally:
if do_close:
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c4191ed1/pylib/cqlshlib/cql3handling.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/cql3handling.py b/pylib/cqlshlib/cql3handling.py
index 3d489d3..1c9b00f 100644
--- a/pylib/cqlshlib/cql3handling.py
+++ b/pylib/cqlshlib/cql3handling.py
@@ -1149,7 +1149,7 @@ def username_name_completer(ctxt, cass):
return [Hint('<username>')]
session = cass.session
- return [maybe_quote(row[0].replace("'", "''")) for row in session.execute("LIST USERS")]
+ return [maybe_quote(row.values()[0].replace("'", "''")) for row in session.execute("LIST USERS")]
# END SYNTAX/COMPLETION RULE DEFINITIONS
@@ -1167,12 +1167,12 @@ class UserTypesMeta(object):
def from_layout(cls, layout):
result = {}
for row in layout:
- ksname = row.keyspace_name
+ ksname = row['keyspace_name']
if ksname not in result:
result[ksname] = {}
- utname = row.type_name
+ utname = row['type_name']
- result[ksname][utname] = zip(row.field_names, row.field_types)
+ result[ksname][utname] = zip(row['field_names'], row['field_types'])
return cls(meta=result)
def get_usertypes_names(self, keyspace):
[2/2] git commit: Merge branch 'cassandra-2.1.0' into cassandra-2.1
Posted by ty...@apache.org.
Merge branch 'cassandra-2.1.0' into cassandra-2.1
Conflicts:
bin/cqlsh
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/1aea6d59
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/1aea6d59
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/1aea6d59
Branch: refs/heads/cassandra-2.1
Commit: 1aea6d5917b258ea22668f1d4a1c7bd6588784bd
Parents: 6e05125 c4191ed
Author: Tyler Hobbs <ty...@datastax.com>
Authored: Wed Aug 20 17:51:40 2014 -0500
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Wed Aug 20 17:51:40 2014 -0500
----------------------------------------------------------------------
CHANGES.txt | 2 ++
bin/cqlsh | 16 +++++++++-------
pylib/cqlshlib/cql3handling.py | 8 ++++----
3 files changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/1aea6d59/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 5103d83,92a177d..f466b72
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,42 -1,6 +1,44 @@@
+2.1.1
+ * (cqlsh) COPY TO/FROM improvements (CASSANDRA-7405)
+ * Support list index operations with conditions (CASSANDRA-7499)
+ * Add max live/tombstoned cells to nodetool cfstats output (CASSANDRA-7731)
+ * Validate IPv6 wildcard addresses properly (CASSANDRA-7680)
+ * (cqlsh) Error when tracing query (CASSANDRA-7613)
+ * Avoid IOOBE when building SyntaxError message snippet (CASSANDRA-7569)
+ * SSTableExport uses correct validator to create string representation of partition
+ keys (CASSANDRA-7498)
+ * Avoid NPEs when receiving type changes for an unknown keyspace (CASSANDRA-7689)
+ * Add support for custom 2i validation (CASSANDRA-7575)
+ * Pig support for hadoop CqlInputFormat (CASSANDRA-6454)
+ * Add listen_interface and rpc_interface options (CASSANDRA-7417)
+ * Improve schema merge performance (CASSANDRA-7444)
+ * Adjust MT depth based on # of partition validating (CASSANDRA-5263)
+ * Optimise NativeCell comparisons (CASSANDRA-6755)
+ * Configurable client timeout for cqlsh (CASSANDRA-7516)
+ * Include snippet of CQL query near syntax error in messages (CASSANDRA-7111)
+Merged from 2.0:
+ * (Hadoop) fix cluster initialisation for a split fetching (CASSANDRA-7774)
+ * Throw InvalidRequestException when queries contain relations on entire
+ collection columns (CASSANDRA-7506)
+ * (cqlsh) enable CTRL-R history search with libedit (CASSANDRA-7577)
+ * (Hadoop) allow ACFRW to limit nodes to local DC (CASSANDRA-7252)
+ * (cqlsh) cqlsh should automatically disable tracing when selecting
+ from system_traces (CASSANDRA-7641)
+ * (Hadoop) Add CqlOutputFormat (CASSANDRA-6927)
+ * Don't depend on cassandra config for nodetool ring (CASSANDRA-7508)
+ * (cqlsh) Fix failing cqlsh formatting tests (CASSANDRA-7703)
+ * Fix IncompatibleClassChangeError from hadoop2 (CASSANDRA-7229)
+ * Add 'nodetool sethintedhandoffthrottlekb' (CASSANDRA-7635)
+ * (cqlsh) Add tab-completion for CREATE/DROP USER IF [NOT] EXISTS (CASSANDRA-7611)
+ * Catch errors when the JVM pulls the rug out from GCInspector (CASSANDRA-5345)
+ * cqlsh fails when version number parts are not int (CASSANDRA-7524)
+Merged from 1.2:
+ * Improve PasswordAuthenticator default super user setup (CASSANDRA-7788)
+
+
2.1.0
+ * (cqlsh) Fix column name formatting for functions, CAS operations,
+ and UDT field selections (CASSANDRA-7806)
* (cqlsh) Fix COPY FROM handling of null/empty primary key
values (CASSANDRA-7792)
* Fix ordering of static cells (CASSANDRA-7763)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/1aea6d59/bin/cqlsh
----------------------------------------------------------------------
diff --cc bin/cqlsh
index 852f4f5,686e07b..340566d
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@@ -522,7 -521,7 +522,8 @@@ class Shell(cmd.Cmd)
self.session = self.conn.connect(keyspace)
else:
self.session = self.conn.connect()
+ self.session.default_timeout = client_timeout
+ self.session.row_factory = ordered_dict_factory
self.get_connection_versions()
self.current_keyspace = keyspace
@@@ -618,11 -613,12 +619,11 @@@
def get_connection_versions(self):
result, = self.session.execute("select * from system.local where key = 'local'")
vers = {
- 'build': result.release_version,
- 'protocol': result.native_protocol_version,
- 'cql': result.cql_version,
+ 'build': result['release_version'],
+ 'protocol': result['native_protocol_version'],
+ 'cql': result['cql_version'],
}
self.connection_versions = vers
- self.cass_ver_tuple = tuple(map(int, vers['build'].split('-', 1)[0].split('.')[:3]))
def get_keyspace_names(self):
return map(str, self.conn.metadata.keyspaces.keys())
@@@ -964,17 -949,13 +965,18 @@@
% DEFAULT_SELECT_LIMIT, color=RED)
self.writeresult("")
-
- def print_static_result(self, rows):
+ def print_static_result(self, rows, cfMetaData):
if not rows:
+ # print header only
+ colnames = cfMetaData.columns.keys() # full header
+ formatted_names = [self.myformat_colname(name, cfMetaData) for name in colnames]
+ self.print_formatted_result(formatted_names, None)
return
+
- colnames = rows[0]._fields
+ colnames = rows[0].keys()
- formatted_names = [self.myformat_colname(name) for name in colnames]
+ formatted_names = [self.myformat_colname(name, cfMetaData) for name in colnames]
- formatted_values = [map(self.myformat_value, row) for row in rows]
+ formatted_values = [map(self.myformat_value, row.values()) for row in rows]
++
if self.expand_enabled:
self.print_formatted_result_vertically(formatted_names, formatted_values)
else:
http://git-wip-us.apache.org/repos/asf/cassandra/blob/1aea6d59/pylib/cqlshlib/cql3handling.py
----------------------------------------------------------------------