added support for static column types #1154

This commit is contained in:
Pawan Kumar 2024-05-14 18:02:39 +05:30
parent d86b19e55f
commit 71eaf3a701
8 changed files with 27 additions and 11 deletions

View File

@ -829,7 +829,7 @@ public class CGWorkloadExporter implements BundledApp {
private String genTableColumnDDL(CqlTable cqltable) {
return cqltable.getColumnDefs().stream()
.map(cd -> cd.getName() + " " + cd.getTrimmedTypedef())
.map(cd -> cd.getName() + " " + cd.getTrimmedTypedef() + (cd.isStatic() ? " STATIC" : ""))
.collect(Collectors.joining(",\n"));
}

View File

@ -430,7 +430,7 @@ columnDefinitionList
//
columnDefinition
: column dataType primaryKeyColumn?
: column dataType (primaryKeyColumn | kwStatic)?
;
//
@ -1013,6 +1013,10 @@ kwFinalfunc
: K_FINALFUNC
;
kwStatic
: K_STATIC
;
kwFrom
: K_FROM
;

View File

@ -25,10 +25,12 @@ public abstract class CqlColumnBase implements NBNamedElement, NBLabeledElement
private String name;
private String typedef;
private ColumnPosition position=ColumnPosition.NonKey;
private boolean isStatic;
protected CqlColumnBase(String colname, String typedef) {
protected CqlColumnBase(String colname, String typedef, boolean isStatic) {
this.typedef = typedef;
this.name = colname;
this.isStatic = isStatic;
}
public void setPosition(ColumnPosition position) {
@ -62,7 +64,7 @@ public abstract class CqlColumnBase implements NBNamedElement, NBLabeledElement
@Override
public NBLabels getLabels() {
return NBLabels.forKV("name", name, "type", "column");
return NBLabels.forKV("name", name, "type", "column", "is_static", isStatic);
}
public boolean isCounter() {
@ -83,4 +85,11 @@ public abstract class CqlColumnBase implements NBNamedElement, NBLabeledElement
protected abstract String getParentFullName();
public boolean isStatic() {
return isStatic;
}
public void setStatic(boolean isStatic) {
this.isStatic = isStatic;
}
}

View File

@ -235,6 +235,7 @@ public class CqlModelBuilder extends CqlParserBaseListener {
CqlTableColumn coldef = new CqlTableColumn(
ctx.column().getText(),
ctx.dataType().getText(),
ctx.kwStatic() != null,
table
);
table.addcolumnDef(coldef);

View File

@ -22,8 +22,8 @@ public class CqlTableColumn extends CqlColumnBase {
private CqlTable table;
public CqlTableColumn(final String colname, final String typedef, final CqlTable table) {
super(colname, typedef);
public CqlTableColumn(final String colname, final String typedef, final boolean isStatic, final CqlTable table) {
super(colname, typedef, isStatic);
this.table = table;
}

View File

@ -23,7 +23,7 @@ public class CqlTypeColumn extends CqlColumnBase {
CqlType type;
public CqlTypeColumn(final String colname, final String typedef, final CqlType usertype) {
super(colname, typedef);
super(colname, typedef, false);
type = usertype;
}

View File

@ -1,5 +1,6 @@
CREATE TABLE cycling.race_winners (
race_name text,
race_position int,
cyclist_name FROZEN<fullname>,
race_name text,
race_position int,
flag int STATIC,
cyclist_name FROZEN<fullname>,
PRIMARY KEY (race_name, race_position));

View File

@ -49,7 +49,8 @@ CREATE TABLE baselines.alltypes
a_varint varint,
an_ascii ascii,
an_inet inet,
an_int int
an_int int,
a_static_int int STATIC
) WITH additional_write_policy = '99PERCENTILE'
AND bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}