diff --git a/bin/cqlsh.py b/bin/cqlsh.py index ded109a..cd948eb 100755 --- a/bin/cqlsh.py +++ b/bin/cqlsh.py @@ -1497,7 +1497,7 @@ def describe_schema_client(self, include_system=False): self.print_recreate_keyspace(k, sys.stdout) print('') - def do_describe(self, parsed): + def do_describe(self, parsed, client_side=False): """ DESCRIBE [cqlsh only] @@ -1589,7 +1589,7 @@ def do_describe(self, parsed): where object can be either a keyspace or a table or an index or a materialized view (in this order). """ - if self.connection_versions['build'][0] < '4': + if client_side: what = parsed.matched[1][1].lower() if what == 'functions': self.describe_functions_client(self.current_keyspace) @@ -1665,6 +1665,10 @@ def do_describe(self, parsed): elif what: self.describe_element(result) + except cassandra.protocol.SyntaxException: + # Server doesn't support DESCRIBE query, retry with + # client-side DESCRIBE implementation + self.do_describe(parsed, client_side=True) except CQL_ERRORS as err: err_msg = err.message if hasattr(err, 'message') else str(err) self.printerr(err_msg.partition("message=")[2].strip('"')) diff --git a/pylib/cqlshlib/test/test_cqlsh_output.py b/pylib/cqlshlib/test/test_cqlsh_output.py index 242dab9..158ae69 100644 --- a/pylib/cqlshlib/test/test_cqlsh_output.py +++ b/pylib/cqlshlib/test/test_cqlsh_output.py @@ -686,7 +686,7 @@ def test_describe_columnfamily_output(self): scylla_table_desc = dedent(""" CREATE TABLE %s.has_all_types ( - num int PRIMARY KEY, + num int, asciicol ascii, bigintcol bigint, blobcol blob, @@ -701,21 +701,24 @@ def test_describe_columnfamily_output(self): tinyintcol tinyint, uuidcol uuid, varcharcol text, - varintcol varint + varintcol varint, + PRIMARY KEY (num) ) WITH bloom_filter_fp_chance = 0.01 - AND caching = {'keys': 'ALL', 'rows_per_partition': 'ALL'} + AND caching = {'keys': 'ALL','rows_per_partition': 'ALL'} AND comment = '' AND compaction = {'class': 'SizeTieredCompactionStrategy'} AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'} - AND crc_check_chance = 1.0 - AND dclocal_read_repair_chance = 0.0 + AND crc_check_chance = 1 + AND dclocal_read_repair_chance = 0 AND default_time_to_live = 0 AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 - AND read_repair_chance = 0.0 - AND speculative_retry = '99.0PERCENTILE'; + AND read_repair_chance = 0 + AND speculative_retry = '99.0PERCENTILE' + AND paxos_grace_seconds = 864000 + AND tombstone_gc = {'mode':'timeout','propagation_delay_in_seconds':'3600'}; """ % quote_name(get_keyspace())) if self.is_scylla: @@ -792,8 +795,9 @@ def test_describe_cluster_output(self): output_re_client = r'''(?x) ^ \n - Cluster: [ ] (?P .* ) \n - Partitioner: [ ] (?P .* ) \n + Cluster: [ ] (?P .* )\n + Partitioner: [ ] (?P .* )\n + Snitch: [ ] (?P .* )\n \n ''' @@ -997,23 +1001,25 @@ def test_scylla_tags(self): expected = dedent(f""" CREATE TABLE {ks}.ccc ( - pkey int PRIMARY KEY + pkey int, + PRIMARY KEY (pkey) ) WITH bloom_filter_fp_chance = 0.01 - AND caching = {{'keys': 'ALL', 'rows_per_partition': 'ALL'}} + AND caching = {{'keys': 'ALL','rows_per_partition': 'ALL'}} AND comment = '' AND compaction = {{'class': 'SizeTieredCompactionStrategy'}} AND compression = {{'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}} - AND crc_check_chance = 1.0 - AND dclocal_read_repair_chance = 0.0 + AND crc_check_chance = 1 + AND dclocal_read_repair_chance = 0 AND default_time_to_live = 0 AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 - AND read_repair_chance = 0.0 - AND speculative_retry = '99.0PERCENTILE'; - - cdc = {{'delta': 'full', 'enabled': 'true', 'postimage': 'false', 'preimage': 'false', 'ttl': '86400'}} + AND read_repair_chance = 0 + AND speculative_retry = '99.0PERCENTILE' + AND paxos_grace_seconds = 864000 + AND tombstone_gc = {{'mode':'timeout','propagation_delay_in_seconds':'3600'}} + AND cdc = {{"delta":"full","enabled":"true","postimage":"false","preimage":"false","ttl":"86400"}}; """) with testrun_cqlsh(tty=True, env=self.default_env) as c: