Skip to content

Commit

Permalink
Revert "[SR SQL Planner Summer Camp][Feature] alter table statement s…
Browse files Browse the repository at this point in the history
…upport of add list partition (#8805)"

This reverts commit fb28ebe.
  • Loading branch information
imay committed Jul 19, 2022
1 parent 8f6979e commit d42c6c1
Show file tree
Hide file tree
Showing 16 changed files with 226 additions and 1,279 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,18 @@ public MultiItemListPartitionDesc(boolean ifNotExists, String partitionName, Lis
this.partitionProperties = partitionProperties;
}

@Override
public Map<String, String> getProperties() {
return this.partitionProperties;
}

@Override
public short getReplicationNum() {
return this.replicationNum;
}

@Override
public DataProperty getPartitionDataProperty() {
return this.partitionDataProperty;
}

@Override
public Long getVersionInfo() {
return versionInfo;
}

@Override
public TTabletType getTabletType() {
return this.tabletType;
}

@Override
public boolean isInMemory() {
return this.isInMemory;
}
Expand All @@ -77,16 +63,10 @@ public List<List<String>> getMultiValues() {
return this.multiValues;
}

@Override
public String getPartitionName() {
return this.partitionName;
}

@Override
public boolean isSetIfNotExists() {
return this.ifNotExists;
}

public List<List<LiteralExpr>> getMultiLiteralExprValues() throws AnalysisException {
List<List<LiteralExpr>> multiPartitionValues = new ArrayList<>(this.multiValues.size());
for (List<String> values : this.multiValues) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@
package com.starrocks.analysis;

import com.starrocks.catalog.Column;
import com.starrocks.catalog.DataProperty;
import com.starrocks.catalog.PartitionInfo;
import com.starrocks.catalog.PartitionType;
import com.starrocks.common.AnalysisException;
import com.starrocks.common.DdlException;
import com.starrocks.thrift.TTabletType;
import org.apache.commons.lang.NotImplementedException;

import java.util.List;
Expand All @@ -41,8 +39,7 @@ public PartitionType getType() {
return type;
}

public void analyze(List<ColumnDef> columnDefs, Map<String, String> otherProperties)
throws AnalysisException {
public void analyze(List<ColumnDef> columnDefs, Map<String, String> otherProperties) throws AnalysisException {
throw new NotImplementedException();
}

Expand All @@ -54,36 +51,4 @@ public PartitionInfo toPartitionInfo(List<Column> columns, Map<String, Long> par
throws DdlException {
throw new NotImplementedException();
}

public String getPartitionName() throws NotImplementedException {
throw new NotImplementedException();
}

public boolean isSetIfNotExists() throws NotImplementedException {
throw new NotImplementedException();
}

public Map<String, String> getProperties() throws NotImplementedException {
throw new NotImplementedException();
}

public short getReplicationNum() throws NotImplementedException {
throw new NotImplementedException();
}

public DataProperty getPartitionDataProperty() throws NotImplementedException {
throw new NotImplementedException();
}

public Long getVersionInfo() throws NotImplementedException {
throw new NotImplementedException();
}

public TTabletType getTabletType() throws NotImplementedException {
throw new NotImplementedException();
}

public boolean isInMemory() throws NotImplementedException {
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,18 @@ public SingleItemListPartitionDesc(boolean ifNotExists, String partitionName, Li
this.partitionProperties = partitionProperties;
}

@Override
public Map<String, String> getProperties() {
return this.partitionProperties;
}

@Override
public short getReplicationNum() {
return this.replicationNum;
}

@Override
public DataProperty getPartitionDataProperty() {
return this.partitionDataProperty;
}

@Override
public Long getVersionInfo() {
return versionInfo;
}

@Override
public TTabletType getTabletType() {
return this.tabletType;
}

@Override
public boolean isInMemory() {
return this.isInMemory;
}
Expand All @@ -77,16 +63,10 @@ public List<String> getValues() {
return this.values;
}

@Override
public String getPartitionName() {
return this.partitionName;
}

@Override
public boolean isSetIfNotExists() {
return ifNotExists;
}

public List<LiteralExpr> getLiteralExprValues() throws AnalysisException {
List<LiteralExpr> partitionValues = new ArrayList<>(this.values.size());
for (String value : this.values) {
Expand Down
64 changes: 5 additions & 59 deletions fe/fe-core/src/main/java/com/starrocks/catalog/CatalogUtils.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
// This file is licensed under the Elastic License 2.0. Copyright 2021-present, StarRocks Limited.
package com.starrocks.catalog;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.starrocks.analysis.LiteralExpr;
import com.starrocks.analysis.MultiItemListPartitionDesc;
import com.starrocks.analysis.PartitionDesc;
import com.starrocks.analysis.SingleItemListPartitionDesc;
import com.starrocks.analysis.SingleRangePartitionDesc;
import com.starrocks.common.AnalysisException;
import com.starrocks.common.DdlException;
import com.starrocks.common.ErrorCode;
Expand All @@ -17,7 +13,6 @@

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

public class CatalogUtils {

Expand Down Expand Up @@ -46,13 +41,13 @@ public static void checkTableState(OlapTable olapTable, String tableName) throws
}

public static Set<String> checkPartitionNameExistForAddPartitions(OlapTable olapTable,
List<PartitionDesc> partitionDescs)
List<SingleRangePartitionDesc> singleRangePartitionDescs)
throws DdlException {
Set<String> existPartitionNameSet = Sets.newHashSet();
for (PartitionDesc partitionDesc : partitionDescs) {
String partitionName = partitionDesc.getPartitionName();
for (SingleRangePartitionDesc singleRangePartitionDesc : singleRangePartitionDescs) {
String partitionName = singleRangePartitionDesc.getPartitionName();
if (olapTable.checkPartitionNameExist(partitionName)) {
if (partitionDesc.isSetIfNotExists()) {
if (singleRangePartitionDesc.isSetIfNotExists()) {
existPartitionNameSet.add(partitionName);
} else {
ErrorReport.reportDdlException(ErrorCode.ERR_SAME_NAME_PARTITION, partitionName);
Expand Down Expand Up @@ -82,53 +77,4 @@ public static void checkIsLakeTable(String dbName, String tableName) throws Anal
db.readUnlock();
}
}

public static void checkPartitionValuesExistForAddListPartition(OlapTable olapTable, PartitionDesc partitionDesc)
throws DdlException {
try {
ListPartitionInfo listPartitionInfo = (ListPartitionInfo) olapTable.getPartitionInfo();
if (partitionDesc instanceof SingleItemListPartitionDesc) {
listPartitionInfo.setBatchLiteralExprValues(listPartitionInfo.getIdToValues());
List<LiteralExpr> allLiteralExprValues = Lists.newArrayList();
listPartitionInfo.getLiteralExprValues().forEach((k, v) -> allLiteralExprValues.addAll(v));

SingleItemListPartitionDesc singleItemListPartitionDesc = (SingleItemListPartitionDesc) partitionDesc;
for (LiteralExpr item : singleItemListPartitionDesc.getLiteralExprValues()) {
for (LiteralExpr value : allLiteralExprValues) {
if (item.getStringValue().equals(value.getStringValue())) {
throw new DdlException("Duplicate partition value %s");
}
}
}
} else if (partitionDesc instanceof MultiItemListPartitionDesc) {
listPartitionInfo.setBatchMultiLiteralExprValues(listPartitionInfo.getIdToMultiValues());
List<List<LiteralExpr>> allMultiLiteralExprValues = Lists.newArrayList();
listPartitionInfo.getMultiLiteralExprValues().forEach((k, v) -> allMultiLiteralExprValues.addAll(v));

int partitionColSize = listPartitionInfo.getPartitionColumns().size();
MultiItemListPartitionDesc multiItemListPartitionDesc = (MultiItemListPartitionDesc) partitionDesc;
for (List<LiteralExpr> itemExpr : multiItemListPartitionDesc.getMultiLiteralExprValues()) {
for (List<LiteralExpr> valueExpr : allMultiLiteralExprValues) {
int duplicatedSize = 0;
for (int i = 0; i < itemExpr.size(); i++) {
String itemValue = itemExpr.get(i).getStringValue();
String value = valueExpr.get(i).getStringValue();
if (value.equals(itemValue)) {
duplicatedSize++;
}
}
if (duplicatedSize == partitionColSize) {
List<String> msg = itemExpr.stream()
.map(value -> ("\"" + value.getStringValue() + "\""))
.collect(Collectors.toList());
throw new DdlException("Duplicate values " +
"(" + String.join(",", msg) + ") ");
}
}
}
}
} catch (AnalysisException e) {
throw new DdlException(e.getMessage());
}
}
}

0 comments on commit d42c6c1

Please sign in to comment.