rename conf disable_if_not_exists to enable_if_exists

This commit is contained in:
Pawan Kumar 2024-07-18 12:22:50 +05:30
parent e2fdbd756a
commit 310de7eee7
2 changed files with 11 additions and 11 deletions

View File

@ -72,7 +72,7 @@ public class CGWorkloadExporter implements BundledApp {
private String namingTemplate; private String namingTemplate;
private double partitionMultiplier; private double partitionMultiplier;
private int quantizerDigits; private int quantizerDigits;
private boolean disableIfNotExists = false; private boolean enableIfExists = true;
private Map<String, List<String>> blockplan = Map.of(); private Map<String, List<String>> blockplan = Map.of();
private final Map<String, Double> timeouts = new HashMap<String, Double>(Map.of( private final Map<String, Double> timeouts = new HashMap<String, Double>(Map.of(
@ -164,8 +164,8 @@ public class CGWorkloadExporter implements BundledApp {
configureTimeouts(cfgmap.get("timeouts")); configureTimeouts(cfgmap.get("timeouts"));
configureBlocks(cfgmap.get("blockplan")); configureBlocks(cfgmap.get("blockplan"));
configureQuantizerDigits(cfgmap.get("quantizer_digits")); configureQuantizerDigits(cfgmap.get("quantizer_digits"));
if (cfgmap.get("disable_if_not_exists").equals(true)) { if (cfgmap.get("enable_if_exists").equals(false)) {
disableIfNotExists = true; enableIfExists = false;
} }
this.model = CqlModelParser.parse(ddl, srcpath); this.model = CqlModelParser.parse(ddl, srcpath);
@ -643,7 +643,7 @@ public class CGWorkloadExporter implements BundledApp {
ops.put( ops.put(
namer.nameFor(table, "optype", "drop", "blockname", blockname), namer.nameFor(table, "optype", "drop", "blockname", blockname),
Map.of( Map.of(
"simple", "drop table if exists " + table.getFullName() + ";", "simple", (enableIfExists ? "drop table if exists " : "drop table ") + table.getFullName() + ";",
"timeout", timeouts.get("drop") "timeout", timeouts.get("drop")
) )
); );
@ -659,7 +659,7 @@ public class CGWorkloadExporter implements BundledApp {
ops.put( ops.put(
namer.nameFor(type, "optype", "drop-type", "blockname", blockname), namer.nameFor(type, "optype", "drop-type", "blockname", blockname),
Map.of( Map.of(
"simple", "drop type if exists " + type.getKeyspace() + "." + type.getName() + ";", "simple", (enableIfExists ? "drop type if exists " : "drop type ") + "." + type.getName() + ";",
"timeout", timeouts.get("drop") "timeout", timeouts.get("drop")
) )
); );
@ -675,7 +675,7 @@ public class CGWorkloadExporter implements BundledApp {
ops.put( ops.put(
namer.nameFor(type, "optype", "drop-keyspace", "blockname", blockname), namer.nameFor(type, "optype", "drop-keyspace", "blockname", blockname),
Map.of( Map.of(
"simple", "drop keyspace if exists " + type.getKeyspace() + ";", "simple", (enableIfExists ? "drop keyspace if exists " : "drop keyspace ") + type.getKeyspace() + ";",
"timeout", timeouts.get("drop") "timeout", timeouts.get("drop")
) )
); );
@ -743,7 +743,7 @@ public class CGWorkloadExporter implements BundledApp {
create keyspace IF_NOT_EXISTS KEYSPACE create keyspace IF_NOT_EXISTS KEYSPACE
with replication = {REPLICATION}DURABLEWRITES?; with replication = {REPLICATION}DURABLEWRITES?;
""" """
.replace("IF_NOT_EXISTS", disableIfNotExists ? "" : "if not exists") .replace("IF_NOT_EXISTS", enableIfExists ? "if not exists" : "")
.replace("KEYSPACE", keyspace.getName()) .replace("KEYSPACE", keyspace.getName())
.replace("REPLICATION", keyspace.getReplicationData()) .replace("REPLICATION", keyspace.getReplicationData())
.replace("DURABLEWRITES?", keyspace.isDurableWrites() ? "" : "\n and durable writes = false") .replace("DURABLEWRITES?", keyspace.isDurableWrites() ? "" : "\n and durable writes = false")
@ -775,7 +775,7 @@ public class CGWorkloadExporter implements BundledApp {
TYPEDEF TYPEDEF
); );
""" """
.replace("IF_NOT_EXISTS", disableIfNotExists ? "" : "if not exists") .replace("IF_NOT_EXISTS", enableIfExists ? "if not exists" : "")
.replace("KEYSPACE", type.getKeyspace().getName()) .replace("KEYSPACE", type.getKeyspace().getName())
.replace("TYPENAME", type.getName()) .replace("TYPENAME", type.getName())
.replace("TYPEDEF", type.getColumnDefs().stream() .replace("TYPEDEF", type.getColumnDefs().stream()
@ -793,7 +793,7 @@ public class CGWorkloadExporter implements BundledApp {
primary key (PRIMARYKEY) primary key (PRIMARYKEY)
)CLUSTERING; )CLUSTERING;
""" """
.replace("IF_NOT_EXISTS", disableIfNotExists ? "" : "if not exists") .replace("IF_NOT_EXISTS", enableIfExists ? "if not exists" : "")
.replace("KEYSPACE", cqltable.getKeyspace().getName()) .replace("KEYSPACE", cqltable.getKeyspace().getName())
.replace("TABLE", cqltable.getName()) .replace("TABLE", cqltable.getName())
.replace("COLUMN_DEFS", genTableColumnDDL(cqltable)) .replace("COLUMN_DEFS", genTableColumnDDL(cqltable))

View File

@ -145,6 +145,6 @@ blockplan:
# not needed when tags=block:'main.*' # not needed when tags=block:'main.*'
# main: insert, select, scan-10, update # main: insert, select, scan-10, update
# Configuration option for removing 'IF NOT EXISTS' in all generated DDL statements # Configuration option for adding 'IF NOT EXISTS' or 'IF EXISTS' in all generated DDL statements
disable_if_not_exists: false enable_if_exists: true