I am struggling to write a regex to basically get 4 groups for both tables
- Table Name e.g. table_v1
- Table columns in first () after table name
- Primary key values in ()
- Optionally Value in () if CLUSTERING ORDER is there
I tried this, mostly works except cannot get cluster order value .
EDIT: HERE IS A FAILING DEMO
re.compile("CREATE\s+TABLE\s+(?:[a-z][a-z0-9_]*).*?((?:[a-z][a-z0-9_"]*)).*?(\(.*?\)) WITH.*?(\(.*?\)).*?;").findall(string_below)
Here is the String trying to run above regex on.
CREATE TABLE abcdeg.table_v1 (
"id" text,
"obj" text,
"version" bigint,
output text,
server text,
PRIMARY KEY ("id", "obj", "version")
) WITH CLUSTERING ORDER BY ("id" ASC, "version" DESC)
AND bloom_filter_fp_chance = 0.1
AND comment = ''
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99.0PERCENTILE';
CREATE TABLE abcdeg.result_v1 (
"id" text,
"obj" text,
time int,
PRIMARY KEY (("id", "obj"))
) WITH bloom_filter_fp_chance = 0.1
AND comment = ''
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND speculative_retry = '99.0PERCENTILE';
CREATE TABLE abcdeg.result_v2 (
"id" text PRIMARY KEY,
"obj" text,
time int
) WITH bloom_filter_fp_chance = 0.1
AND comment = ''
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND speculative_retry = '99.0PERCENTILE';