hello-stephen commented on code in PR #70352:
URL: https://github.com/apache/doris/pull/70352#discussion_r4723257272


##########
fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java:
##########
@@ -2179,37 +2201,75 @@ public int getAsInt() {
                     buildIndexChange = true;
                     lightSchemaChange = false;
                 } else if (alterClause instanceof DropIndexClause) {
-                    if (processDropIndex((DropIndexClause) alterClause, 
olapTable, newIndexes)) {
-                        return;
-                    }
-                    lightSchemaChange = false;
-
                     DropIndexClause dropIndexClause = (DropIndexClause) 
alterClause;
-                    List<Index> existedIndexes = olapTable.getIndexes();
-                    Index found = null;
-                    for (Index existedIdx : existedIndexes) {
-                        if 
(existedIdx.getIndexName().equalsIgnoreCase(dropIndexClause.getIndexName())) {
-                            found = existedIdx;
-                            break;
+
+                    if (dropIndexClause.hasPartitionSpec()) {
+                        // Delete the physical index files and keep the 
table-level index definition.
+                        List<Index> existedIndexes = olapTable.getIndexes();
+                        Index found = null;
+                        for (Index existedIdx : existedIndexes) {
+                            if 
(existedIdx.getIndexName().equalsIgnoreCase(dropIndexClause.getIndexName())) {
+                                found = existedIdx;
+                                break;
+                            }
                         }
-                    }
-                    // for inverted index, light schema change is supported in 
both cloud and local mode;
-                    // for ngram index, light schema change is supported only 
in cloud mode;
-                    boolean supportLightIndexChange = false;
-                    if (Config.isCloudMode()) {
-                        if (enableAddIndexForNewData) {
-                            supportLightIndexChange = (
-                                    found.getIndexType() == IndexType.NGRAM_BF
-                                            || found.getIndexType() == 
IndexDef.IndexType.INVERTED);
+                        if (found == null) {
+                            if (dropIndexClause.isSetIfExists()) {
+                                LOG.info("drop index[{}] which does not exist 
on table[{}]",
+                                        dropIndexClause.getIndexName(), 
olapTable.getName());
+                                return;
+                            }
+                            throw new DdlException("index " + 
dropIndexClause.getIndexName() + " does not exist");
                         }
-                    } else {
-                        supportLightIndexChange = found.getIndexType() == 
IndexDef.IndexType.INVERTED
-                                || found.getIndexType() == 
IndexDef.IndexType.ANN;
-                    }
-                    if (found != null && supportLightIndexChange) {
+                        if (found.getIndexType() != IndexType.INVERTED) {

Review Comment:
   [P2] Reject VARIANT indexes before scheduling partition drops
   
   For a local partitioned table with `v VARIANT, INDEX idx_v(v) USING 
INVERTED` and populated indexed subcolumns, `DROP INDEX idx_v ON t PARTITION 
(p1)` passes this check. The task names the root column `v`, but 
`IndexBuilder::update_inverted_index_info()` calls 
`TabletSchema::inverted_indexs(v)`, which returns empty because 
`check_support_inverted_index()` rejects root VARIANT columns. No index is 
removed from the rowset schema or added to `_dropped_inverted_indexes`; V2 
copies all directories and SNII retains its container, then the job reaches 
FINISHED with the index still present. Reject these indexes here (also 
preserving the existing `field_pattern` restriction), or implement removal of 
their derived subcolumn indexes before accepting the statement.



-- 
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]

Reply via email to