scylla-tools-java icon indicating copy to clipboard operation
scylla-tools-java copied to clipboard

Better printing of CDC options in DESCRIBE TABLE in cqlsh

Open avelanarius opened this issue 3 years ago • 7 comments

Currently, cqlsh prints CDC options in DESCRIBE TABLE queries in a separate line:

cqlsh> DESCRIBE TABLE ks.t;

CREATE TABLE ks.t (
    pk int,
    ck int,
    v int,
    v2 int,
    PRIMARY KEY (pk, ck)
) WITH CLUSTERING ORDER BY (ck ASC)
    AND bloom_filter_fp_chance = 0.01
    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 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 = {'postimage': 'false', 'preimage': 'true', 'ttl': '86400', 'enabled': 'true', 'delta': 'full'}

I think it would be better to print those options not in a separate line, but within the CREATE TABLE statement. That way it is more consistent with other options and easily copyable:

cqlsh> DESCRIBE TABLE ks.t;

CREATE TABLE ks.t (
    pk int,
    ck int,
    v int,
    v2 int,
    PRIMARY KEY (pk, ck)
) WITH CLUSTERING ORDER BY (ck ASC)
    AND bloom_filter_fp_chance = 0.01
    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 cdc = {'postimage': 'false', 'preimage': 'true', 'ttl': '86400', 'enabled': 'true', 'delta': 'full'}
    AND crc_check_chance = 1.0
    AND dclocal_read_repair_chance = 0.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';

(for a reference, Java Driver 3.x already prints it in that format when using toString() after this commit: https://github.com/scylladb/java-driver/commit/ae2254a2e6458fe99bb764af24d68df2590171d7)

avelanarius avatar Apr 14 '21 16:04 avelanarius

/cc @jul-stas (I think you implemented printing of CDC options in cqlsh, was there a important reason for printing those options in a separate line?)

avelanarius avatar Apr 14 '21 16:04 avelanarius

@avelanarius IIRC the reason was to separate schema extensions from regular table options. In general, putting schema extensions among "normal" options, like AND schema_extension_X = abc, can lead to an incorrect CREATE statement. Maybe it's not the case with CDC schema extension so it can have special treatment while printing...

jul-stas avatar Apr 15 '21 08:04 jul-stas

I think server side DESCRIBE should solve this one...

fruch avatar Jul 30 '23 22:07 fruch

Small note: CDC options in server-side DESCRIBE were added only recently (5.2, 5.3 doesn't have it): https://github.com/scylladb/scylladb/commit/62ced6670231aa013acdfb2d1f4913a7b238e2db

avelanarius avatar Jul 31 '23 10:07 avelanarius

@fruch - shall I move it to cqlsh repo?

mykaul avatar Dec 28 '23 15:12 mykaul

@fruch - shall I move it to cqlsh repo?

You can move it

But it would need to be part of the scylla core as well, cause the server side describe

fruch avatar Dec 28 '23 16:12 fruch

@fruch - shall I move it to cqlsh repo?

You can move it

But it would need to be part of the scylla core as well, cause the server side describe

I'll need to understand better what is needed in core - please open a separate issue if neede.

mykaul avatar Jan 01 '24 07:01 mykaul