Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ partitionsDef
;

partitionDef
: (lessThanPartitionDef | fixedPartitionDef | stepPartitionDef | inPartitionDef) properties=propertyClause?
: (lessThanPartitionDef | fixedPartitionDef | stepPartitionDef | inPartitionDef) (LEFT_PAREN partitionProperties=propertyItemList RIGHT_PAREN)?
;

lessThanPartitionDef
Expand Down
26 changes: 0 additions & 26 deletions fe/fe-core/src/main/cup/sql_parser.cup
Original file line number Diff line number Diff line change
Expand Up @@ -1800,19 +1800,6 @@ create_stmt ::=
RESULT = new CreateTableStmt(ifNotExists, isExternal, name, columns, engineName, keys, partition,
distribution, tblProperties, extProperties, tableComment, index);
:}
| KW_CREATE opt_external:isExternal KW_TABLE opt_if_not_exists:ifNotExists table_name:name
LPAREN column_definition_list:columns COMMA RPAREN opt_engine:engineName
opt_keys:keys
opt_comment:tableComment
opt_partition:partition
opt_distribution:distribution
opt_rollup:index
opt_properties:tblProperties
opt_ext_properties:extProperties
{:
RESULT = new CreateTableStmt(ifNotExists, isExternal, name, columns, null, engineName, keys, partition,
distribution, tblProperties, extProperties, tableComment, index);
:}
| KW_CREATE opt_external:isExternal KW_TABLE opt_if_not_exists:ifNotExists table_name:name
LPAREN column_definition_list:columns COMMA index_definition_list:indexes RPAREN opt_engine:engineName
opt_keys:keys
Expand All @@ -1826,19 +1813,6 @@ create_stmt ::=
RESULT = new CreateTableStmt(ifNotExists, isExternal, name, columns, indexes, engineName, keys, partition,
distribution, tblProperties, extProperties, tableComment, index);
:}
| KW_CREATE opt_external:isExternal KW_TABLE opt_if_not_exists:ifNotExists table_name:name
LPAREN column_definition_list:columns COMMA index_definition_list:indexes COMMA RPAREN opt_engine:engineName
opt_keys:keys
opt_comment:tableComment
opt_partition:partition
opt_distribution:distribution
opt_rollup:index
opt_properties:tblProperties
opt_ext_properties:extProperties
{:
RESULT = new CreateTableStmt(ifNotExists, isExternal, name, columns, indexes, engineName, keys, partition,
distribution, tblProperties, extProperties, tableComment, index);
:}
| KW_CREATE opt_external:isExternal KW_TABLE opt_if_not_exists:ifNotExists table_name:name
opt_col_list:columns
opt_engine:engineName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,22 @@ public SinglePartitionDesc(boolean ifNotExists, String partName, PartitionKeyDes
/**
* for Nereids
*/
public SinglePartitionDesc(boolean ifNotExists, String partName, PartitionKeyDesc partitionKeyDesc,
ReplicaAllocation replicaAlloc, Map<String, String> properties) {
this.ifNotExists = ifNotExists;

public SinglePartitionDesc(boolean ifNotExists, String partName,
PartitionKeyDesc partitionKeyDesc, ReplicaAllocation replicaAlloc,
Map<String, String> properties, DataProperty partitionDataProperty, boolean isInMemory,
TTabletType tabletType, Long versionInfo, String storagePolicy, boolean isMutable) {
this.isAnalyzed = true;

this.ifNotExists = ifNotExists;
this.partName = partName;
this.partitionKeyDesc = partitionKeyDesc;
this.properties = properties;

this.partitionDataProperty = new DataProperty(DataProperty.DEFAULT_STORAGE_MEDIUM);
this.partitionDataProperty = partitionDataProperty;
this.replicaAlloc = replicaAlloc;
this.storagePolicy = "";
this.isInMemory = isInMemory;
this.tabletType = tabletType;
this.versionInfo = versionInfo;
this.storagePolicy = storagePolicy;
this.isMutable = isMutable;
}

public boolean isSetIfNotExists() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2430,26 +2430,35 @@ public IndexDefinition visitIndexDef(IndexDefContext ctx) {
String indexName = ctx.indexName.getText();
List<String> indexCols = visitIdentifierList(ctx.cols);
Map<String, String> properties = visitPropertyItemList(ctx.properties);
String indexType = ctx.indexType.getText();
String indexType = ctx.indexType != null ? ctx.indexType.getText() : null;
String comment = ctx.comment != null ? ctx.comment.getText() : "";
return new IndexDefinition(indexName, indexCols, indexType, properties, comment);
}

@Override
public List<PartitionDefinition> visitPartitionsDef(PartitionsDefContext ctx) {
return ctx.partitions.stream()
.map(p -> ((PartitionDefinition) visit(p)).withProperties(visitPropertyClause(p.properties)))
.collect(Collectors.toList());
.map(p -> ((PartitionDefinition) visit(p))).collect(Collectors.toList());
}

@Override
public PartitionDefinition visitPartitionDef(DorisParser.PartitionDefContext ctx) {
PartitionDefinition partitionDefinition = (PartitionDefinition) visit(ctx.getChild(0));
if (ctx.partitionProperties != null) {
partitionDefinition.withProperties(visitPropertyItemList(ctx.partitionProperties));
}
return partitionDefinition;
}

@Override
public PartitionDefinition visitLessThanPartitionDef(LessThanPartitionDefContext ctx) {
String partitionName = ctx.partitionName.getText();
if (ctx.MAXVALUE() == null) {
List<Expression> lessThanValues = visitConstantSeq(ctx.constantSeq());
return new LessThanPartition(partitionName, lessThanValues);
return new LessThanPartition(ctx.EXISTS() != null, partitionName, lessThanValues);
} else {
return new LessThanPartition(partitionName, ImmutableList.of(MaxValue.INSTANCE));
return new LessThanPartition(ctx.EXISTS() != null, partitionName,
ImmutableList.of(MaxValue.INSTANCE));
}
}

Expand All @@ -2458,15 +2467,15 @@ public PartitionDefinition visitFixedPartitionDef(FixedPartitionDefContext ctx)
String partitionName = ctx.partitionName.getText();
List<Expression> lowerBounds = visitConstantSeq(ctx.lower);
List<Expression> upperBounds = visitConstantSeq(ctx.upper);
return new FixedRangePartition(partitionName, lowerBounds, upperBounds);
return new FixedRangePartition(ctx.EXISTS() != null, partitionName, lowerBounds, upperBounds);
}

@Override
public PartitionDefinition visitStepPartitionDef(StepPartitionDefContext ctx) {
List<Expression> fromExpression = visitConstantSeq(ctx.from);
List<Expression> toExpression = visitConstantSeq(ctx.to);
return new StepPartition(fromExpression, toExpression, Long.parseLong(ctx.unitsAmount.getText()),
ctx.unit != null ? ctx.unit.getText() : null);
return new StepPartition(false, null, fromExpression, toExpression,
Long.parseLong(ctx.unitsAmount.getText()), ctx.unit != null ? ctx.unit.getText() : null);
}

@Override
Expand All @@ -2479,7 +2488,7 @@ public PartitionDefinition visitInPartitionDef(InPartitionDefContext ctx) {
values = visitConstantSeq(ctx.constants).stream().map(ImmutableList::of)
.collect(Collectors.toList());
}
return new InPartition(ctx.partitionName.getText(), values);
return new InPartition(ctx.EXISTS() != null, ctx.partitionName.getText(), values);
}

@Override
Expand Down
Loading