Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server side describe #2

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions bin/cqlsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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('"'))
Expand Down
40 changes: 23 additions & 17 deletions pylib/cqlshlib/test/test_cqlsh_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down Expand Up @@ -792,8 +795,9 @@ def test_describe_cluster_output(self):
output_re_client = r'''(?x)
^
\n
Cluster: [ ] (?P<clustername> .* ) \n
Partitioner: [ ] (?P<partitionername> .* ) \n
Cluster: [ ] (?P<clustername> .* )\n
Partitioner: [ ] (?P<partitionername> .* )\n
Snitch: [ ] (?P<snitchname> .* )\n
\n
'''

Expand Down Expand Up @@ -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:
Expand Down
Loading