Tanya-W commented on code in PR #19063:
URL: https://github.com/apache/doris/pull/19063#discussion_r1193430836
##########
fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java:
##########
@@ -1833,36 +1902,69 @@ public int getAsInt() {
// do nothing, properties are already in propertyMap
lightSchemaChange = false;
} else if (alterClause instanceof CreateIndexClause) {
- if (processAddIndex((CreateIndexClause) alterClause,
olapTable, newIndexes)) {
+ CreateIndexClause createIndexClause = (CreateIndexClause)
alterClause;
+ IndexDef indexDef = createIndexClause.getIndexDef();
+ Index index = createIndexClause.getIndex();
+ if (indexDef.isBuildDeferred()) {
+ if (!olapTable.isPartitioned()) {
+ List<String> specifiedPartitions =
indexDef.getPartitionNames();
+ if (!specifiedPartitions.isEmpty()) {
+ throw new DdlException("table " +
olapTable.getName()
+ + " is not partitioned, cannot build
index with partitions.");
+ }
+ }
+ List<Index> existedIndexes = olapTable.getIndexes();
+ for (Index existedIdx : existedIndexes) {
+ if
(existedIdx.getIndexName().equalsIgnoreCase(indexDef.getIndexName())) {
+ isBuildInvertedIndex = true;
+ index.setIndexId(existedIdx.getIndexId());
+ index.setColumns(existedIdx.getColumns());
+
index.setProperties(existedIdx.getProperties());
+ if (indexDef.getPartitionNames().isEmpty()) {
+
invertedIndexOnPartitions.put(index.getIndexId(),
olapTable.getPartitionNames());
Review Comment:
The two branch difference is if no partition is specified, the default is to
use the full table partition
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]