Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C47A018160 for ; Fri, 18 Dec 2015 23:30:55 +0000 (UTC) Received: (qmail 87248 invoked by uid 500); 18 Dec 2015 23:30:55 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 87183 invoked by uid 500); 18 Dec 2015 23:30:55 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 86905 invoked by uid 99); 18 Dec 2015 23:30:55 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Dec 2015 23:30:55 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3F52FE054A; Fri, 18 Dec 2015 23:30:55 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aleksey@apache.org To: commits@cassandra.apache.org Date: Fri, 18 Dec 2015 23:30:55 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/3] cassandra git commit: (cqlsh) show correct column names for empty result sets Repository: cassandra Updated Branches: refs/heads/trunk 99880d22d -> 01b3508e0 (cqlsh) show correct column names for empty result sets patch by Adam Holmberg; reviewed by Ariel Weisberg for CASSANDRA-9813 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/bcd68b54 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/bcd68b54 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/bcd68b54 Branch: refs/heads/trunk Commit: bcd68b546b7e449afd5f4233e01a45e0e4609307 Parents: 9dd2b5e Author: Adam Holmberg Authored: Fri Dec 11 16:18:49 2015 -0600 Committer: Aleksey Yeschenko Committed: Fri Dec 18 23:26:53 2015 +0000 ---------------------------------------------------------------------- CHANGES.txt | 1 + bin/cqlsh.py | 21 +++++++-------------- 2 files changed, 8 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/bcd68b54/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 1480960..88ef42e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.2.5 + * (cqlsh) show correct column names for empty result sets (CASSANDRA-9813) * Add new types to Stress (CASSANDRA-9556) * Add property to allow listening on broadcast interface (CASSANDRA-9748) * Fix regression in split size on CqlInputFormat (CASSANDRA-10835) http://git-wip-us.apache.org/repos/asf/cassandra/blob/bcd68b54/bin/cqlsh.py ---------------------------------------------------------------------- diff --git a/bin/cqlsh.py b/bin/cqlsh.py index 1119289..427fc29 100644 --- a/bin/cqlsh.py +++ b/bin/cqlsh.py @@ -1242,7 +1242,7 @@ class Shell(cmd.Cmd): elif result: # CAS INSERT/UPDATE self.writeresult("") - self.print_static_result(list(result), self.parse_for_table_meta(statement.query_string)) + self.print_static_result(result.column_names, list(result), self.parse_for_table_meta(statement.query_string)) self.flush_output() return True, future @@ -1256,7 +1256,7 @@ class Shell(cmd.Cmd): page = result.current_rows if page: num_rows += len(page) - self.print_static_result(page, table_meta) + self.print_static_result(result.column_names, page, table_meta) if result.has_more_pages: raw_input("---MORE---") result.fetch_next_page() @@ -1265,7 +1265,7 @@ class Shell(cmd.Cmd): else: rows = list(result) num_rows = len(rows) - self.print_static_result(rows, table_meta) + self.print_static_result(result.column_names, rows, table_meta) self.writeresult("(%d rows)" % num_rows) if self.decoding_errors: @@ -1275,18 +1275,11 @@ class Shell(cmd.Cmd): self.writeresult('%d more decoding errors suppressed.' % (len(self.decoding_errors) - 2), color=RED) - def print_static_result(self, rows, table_meta): - if not rows: - if not table_meta: - return - # print header only - colnames = table_meta.columns.keys() # full header - formatted_names = [self.myformat_colname(name, table_meta) for name in colnames] - self.print_formatted_result(formatted_names, None) + def print_static_result(self, column_names, rows, table_meta): + if not column_names and not table_meta: return - - colnames = rows[0].keys() - formatted_names = [self.myformat_colname(name, table_meta) for name in colnames] + column_names = column_names or table_meta.columns.keys() + formatted_names = [self.myformat_colname(name, table_meta) for name in column_names] formatted_values = [map(self.myformat_value, row.values()) for row in rows] if self.expand_enabled: