cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [5/6] git commit: cqlsh: add DESC COLUMNFAMILIES to show cf names
Date Thu, 19 Jan 2012 23:04:53 GMT
cqlsh: add DESC COLUMNFAMILIES to show cf names

as opposed to DESCRIBE KEYSPACE, which shows all columnfamilies but
includes all their column definitions and options, which is usually a
lot of output.

patch by pcannon; reviewed by jbellis for CASSANDRA-3586


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/95942f02
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/95942f02
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/95942f02

Branch: refs/heads/cassandra-1.0
Commit: 95942f0221240e47e950a387a440b4dbe7dada65
Parents: 8311965
Author: paul cannon <paul@datastax.com>
Authored: Thu Jan 19 14:23:56 2012 -0600
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Thu Jan 19 17:02:36 2012 -0600

----------------------------------------------------------------------
 CHANGES.txt |    4 ++++
 bin/cqlsh   |   29 ++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/95942f02/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index d3919d7..4688381 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,7 @@
+1.0.8
+ * (cqlsh) add DESCRIBE COLUMNFAMILIES (CASSANDRA-3586)
+
+
 1.0.7
  * fix regression in HH page size calculation (CASSANDRA-3624)
  * retry failed stream on IOException (CASSANDRA-3686)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/95942f02/bin/cqlsh
----------------------------------------------------------------------
diff --git a/bin/cqlsh b/bin/cqlsh
index 0f02a0c..8fe044c 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -136,6 +136,7 @@ cqlhandling.CqlRuleSet.append_rules(r'''
 
 <describeCommand> ::= "DESCRIBE" ( "KEYSPACE" ksname=<name>?
                                   | "COLUMNFAMILY" cfname=<name>
+                                  | "COLUMNFAMILIES"
                                   | "SCHEMA"
                                   | "CLUSTER" )
                     ;
@@ -205,6 +206,9 @@ def complete_assume_col(ctxt, cqlsh):
 class NoKeyspaceError(Exception):
     pass
 
+class KeyspaceNotFound(Exception):
+    pass
+
 def trim_if_present(s, prefix):
     if s.startswith(prefix):
         return s[len(prefix):]
@@ -697,6 +701,22 @@ class Shell(cmd.Cmd):
         self.print_recreate_columnfamily(self.get_columnfamily(cfname))
         self.printout('')
 
+    def describe_columnfamilies(self, ksname):
+        if ksname is None:
+            for k in self.get_keyspaces():
+                self.printout('Keyspace %s' % (k.name,))
+                self.printout('---------%s\n' % ('-' * len(k.name)))
+                cmd.Cmd.columnize(self, [c.name for c in k.cf_defs])
+                self.printout('')
+        else:
+            try:
+                names = self.get_columnfamily_names(ksname)
+            except cql.cassandra.ttypes.NotFoundException:
+                raise KeyspaceNotFound('Keyspace %s not found.' % (ksname,))
+            self.printout('')
+            cmd.Cmd.columnize(self, names)
+            self.printout('')
+
     def describe_cluster(self):
         self.printout('Cluster: %s' % self.get_cluster_name())
         p = trim_if_present(self.get_partitioner(), 'org.apache.cassandra.dht.')
@@ -724,7 +744,7 @@ class Shell(cmd.Cmd):
           Outputs information about the connected Cassandra cluster, or about
           the data stored on it. Use in one of the following ways:
 
-        DESCRIBE KEYSPACE <keyspacename>
+        DESCRIBE KEYSPACE [<keyspacename>]
 
           Output CQL commands that could be used to recreate the given
           keyspace, and the columnfamilies in it. In some cases, as the CQL
@@ -734,6 +754,11 @@ class Shell(cmd.Cmd):
           The '<keyspacename>' argument may be omitted when using a non-system
           keyspace; in that case, the current keyspace will be described.
 
+        DESCRIBE COLUMNFAMILIES
+
+          Output the names of all column families in the current keyspace, or
+          in all keyspaces if there is no current keyspace.
+
         DESCRIBE COLUMNFAMILY <columnfamilyname>
 
           Output CQL commands that could be used to recreate the given
@@ -766,6 +791,8 @@ class Shell(cmd.Cmd):
         elif what == 'columnfamily':
             cfname = cql_dequote(parsed.get_binding('cfname'))
             self.describe_columnfamily(cfname)
+        elif what == 'columnfamilies':
+            self.describe_columnfamilies(self.current_keyspace)
         elif what == 'cluster':
             self.describe_cluster()
         elif what == 'schema':


Mime
View raw message