diff --git a/bin/cqlsh.py b/bin/cqlsh.py index 328ba30a9d..36daa51687 100644 --- a/bin/cqlsh.py +++ b/bin/cqlsh.py @@ -284,9 +284,9 @@ cqlsh_extra_syntax_rules = r''' ; ::= ( "DESCRIBE" | "DESC" ) - ( "FUNCTIONS" ksname=? + ( "FUNCTIONS" | "FUNCTION" udf= - | "AGGREGATES" ksname=? + | "AGGREGATES" | "AGGREGATE" uda= | "KEYSPACES" | "KEYSPACE" ksname=? @@ -1486,7 +1486,7 @@ class Shell(cmd.Cmd): cmd.Cmd.columnize(self, protect_names(self.get_columnfamily_names(ksname))) print - def describe_functions(self, ksname=None): + def describe_functions(self, ksname): print if ksname is None: for ksmeta in self.get_keyspaces(): @@ -1513,7 +1513,7 @@ class Shell(cmd.Cmd): print "\n\n".join(func.as_cql_query(formatted=True) for func in functions) print - def describe_aggregates(self, ksname=None): + def describe_aggregates(self, ksname): print if ksname is None: for ksmeta in self.get_keyspaces(): @@ -1596,7 +1596,7 @@ class Shell(cmd.Cmd): (DESC may be used as a shorthand.) Outputs information about the connected Cassandra cluster, or about - the data stored on it. Use in one of the following ways: + the data objects stored in the cluster. Use in one of the following ways: DESCRIBE KEYSPACES @@ -1604,20 +1604,20 @@ class Shell(cmd.Cmd): DESCRIBE KEYSPACE [] - Output CQL commands that could be used to recreate the given - keyspace, and the tables in it. In some cases, as the CQL interface - matures, there will be some metadata about a keyspace that is not - representable with CQL. That metadata will not be shown. + Output CQL commands that could be used to recreate the given keyspace, + and the objects in it (such as tables, types, functions, etc.). + In some cases, as the CQL interface matures, there will be some metadata + about a keyspace that is not representable with CQL. That metadata will not be shown. - The '' argument may be omitted when using a non-system - keyspace; in that case, the current keyspace will be described. + The '' argument may be omitted, in which case the current + keyspace will be described. DESCRIBE TABLES Output the names of all tables in the current keyspace, or in all keyspaces if there is no current keyspace. - DESCRIBE TABLE + DESCRIBE TABLE [.] Output CQL commands that could be used to recreate the given table. In some cases, as above, there may be table metadata which is not @@ -1625,13 +1625,13 @@ class Shell(cmd.Cmd): DESCRIBE INDEX - Output CQL commands that could be used to recreate the given index. + Output the CQL command that could be used to recreate the given index. In some cases, there may be index metadata which is not representable and which will not be shown. DESCRIBE MATERIALIZED VIEW - Output CQL commands that could be used to recreate the given materialized view. + Output the CQL command that could be used to recreate the given materialized view. In some cases, there may be materialized view metadata which is not representable and which will not be shown. @@ -1648,21 +1648,32 @@ class Shell(cmd.Cmd): Works as though "DESCRIBE KEYSPACE k" was invoked for each non-system keyspace k. Use DESCRIBE FULL SCHEMA to include the system keyspaces. - DESCRIBE FUNCTIONS + DESCRIBE TYPES - Output the names of all user defined functions in the given keyspace. + Output the names of all user-defined-types in the current keyspace, or in all + keyspaces if there is no current keyspace. + + DESCRIBE TYPE [.] + + Output the CQL command that could be used to recreate the given user-defined-type. + + DESCRIBE FUNCTIONS + + Output the names of all user-defined-functions in the current keyspace, or in all + keyspaces if there is no current keyspace. DESCRIBE FUNCTION [.] - Describe the given user defined function. + Output the CQL command that could be used to recreate the given user-defined-function. - DESCRIBE AGGREGATES + DESCRIBE AGGREGATES - Output the names of all user defined aggregates in the given keyspace. + Output the names of all user-defined-aggregates in the current keyspace, or in all + keyspaces if there is no current keyspace. DESCRIBE AGGREGATE [.] - Describe the given user defined aggregate. + Output the CQL command that could be used to recreate the given user-defined-aggregate. DESCRIBE @@ -1672,15 +1683,13 @@ class Shell(cmd.Cmd): """ what = parsed.matched[1][1].lower() if what == 'functions': - ksname = self.cql_unprotect_name(parsed.get_binding('ksname', None)) - self.describe_functions(ksname) + self.describe_functions(self.current_keyspace) elif what == 'function': ksname = self.cql_unprotect_name(parsed.get_binding('ksname', None)) functionname = self.cql_unprotect_name(parsed.get_binding('udfname')) self.describe_function(ksname, functionname) elif what == 'aggregates': - ksname = self.cql_unprotect_name(parsed.get_binding('ksname', None)) - self.describe_aggregates(ksname) + self.describe_aggregates(self.current_keyspace) elif what == 'aggregate': ksname = self.cql_unprotect_name(parsed.get_binding('ksname', None)) aggregatename = self.cql_unprotect_name(parsed.get_binding('udaname'))