[opt](inverted index) support the same column create different type index (#21972)

This commit is contained in:
YueW
2023-07-21 23:02:39 +08:00
committed by GitHub
parent acf4aa2818
commit ef01988ae1
7 changed files with 371 additions and 4 deletions

View File

@ -2676,6 +2676,7 @@ public class SchemaChangeHandler extends AlterHandler {
}
}
currentIndexMeta.setMaxColUniqueId(maxColUniqueId);
currentIndexMeta.setIndexes(indexes);
}
olapTable.setIndexes(indexes);
olapTable.rebuildFullSchema();

View File

@ -17,6 +17,7 @@
package org.apache.doris.analysis;
import org.apache.doris.analysis.IndexDef.IndexType;
import org.apache.doris.catalog.AggregateType;
import org.apache.doris.catalog.Column;
import org.apache.doris.catalog.DistributionInfo;
@ -32,6 +33,7 @@ import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.ErrorReport;
import org.apache.doris.common.FeConstants;
import org.apache.doris.common.FeNameFormat;
import org.apache.doris.common.Pair;
import org.apache.doris.common.UserException;
import org.apache.doris.common.util.AutoBucketUtils;
import org.apache.doris.common.util.ParseUtil;
@ -591,7 +593,7 @@ public class CreateTableStmt extends DdlStmt {
if (CollectionUtils.isNotEmpty(indexDefs)) {
Set<String> distinct = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
Set<List<String>> distinctCol = new HashSet<>();
Set<Pair<IndexType, List<String>>> distinctCol = new HashSet<>();
for (IndexDef indexDef : indexDefs) {
indexDef.analyze();
@ -616,13 +618,14 @@ public class CreateTableStmt extends DdlStmt {
indexDef.getColumns(), indexDef.getIndexType(),
indexDef.getProperties(), indexDef.getComment()));
distinct.add(indexDef.getIndexName());
distinctCol.add(indexDef.getColumns().stream().map(String::toUpperCase).collect(Collectors.toList()));
distinctCol.add(Pair.of(indexDef.getIndexType(),
indexDef.getColumns().stream().map(String::toUpperCase).collect(Collectors.toList())));
}
if (distinct.size() != indexes.size()) {
throw new AnalysisException("index name must be unique.");
}
if (distinctCol.size() != indexes.size()) {
throw new AnalysisException("same index columns have multiple index name is not allowed.");
throw new AnalysisException("same index columns have multiple same type index is not allowed.");
}
}
}

View File

@ -140,6 +140,10 @@ public class MaterializedIndexMeta implements Writable, GsonPostProcessable {
return indexes != null ? indexes : Lists.newArrayList();
}
public void setIndexes(List<Index> newIndexes) {
this.indexes = newIndexes;
}
public List<Column> getSchema() {
return getSchema(true);
}