airborne12 opened a new pull request, #71122:
URL: https://github.com/apache/doris/pull/71122
### Background
`DROP INDEX <index> ON <table> PARTITION (...)`, and its `ALTER TABLE ...
DROP INDEX ... PARTITION` form, deletes the files of an inverted index on the
named partitions and keeps the index in the table schema. The FE creates one
index change job per partition. On each tablet, the BE `IndexBuilder` finds the
index in each rowset's schema through the column that the job names, rewrites
the rowset without it, and the job then reports FINISHED. An inverted index on
a VARIANT column is written for the column's subcolumns (paths), not for the
root column.
### What problem does this PR solve?
Issue Number: None
Related PR: #62181 (introduced DROP INDEX ON PARTITION), #70357 (same
feature on branch-4.1), #70352 (branch-4.2 backport where the bug was
reported), #71041 (rejects the statement in cloud mode; touches the same
regression suite)
PR Type: Bugfix
Problem Summary:
On a shared-nothing cluster, DROP INDEX ON PARTITION on an inverted index of
a VARIANT column, including a `field_pattern` index, is accepted and its job
reaches FINISHED, but the index stays on the partition: the BE rewrites each
rowset and copies every index file unchanged. This PR rejects the statement for
indexes on VARIANT columns, as BUILD INDEX already does.
```sql
CREATE TABLE t (k INT NOT NULL, v VARIANT, s STRING,
INDEX idx_v (v) USING INVERTED, INDEX idx_s (s) USING INVERTED)
DUPLICATE KEY(k)
PARTITION BY RANGE(k) (PARTITION p1 VALUES LESS THAN (3000), PARTITION p2
VALUES LESS THAN (MAXVALUE))
DISTRIBUTED BY HASH(k) BUCKETS 1 PROPERTIES ("replication_num" = "1");
-- load rows with v = {"a": "tag<n % 10>", "b": <n>} and s = 'tag<n % 10>'
DROP INDEX idx_v ON t PARTITION (p1);
SET enable_match_without_inverted_index = false;
SELECT count(*) FROM t PARTITION (p1) WHERE cast(v['a'] AS STRING) MATCH
'tag3';
```
| | Before the fix | With the fix |
|---|---|---|
| `DROP INDEX idx_v ON t PARTITION (p1)` | Accepted, job `FINISHED`; the p1
rowset keeps `idx_v` in its schema and its `.idx` file stays 13411 bytes; the
MATCH on p1 still returns `300` | `DROP INDEX ON PARTITION is not supported for
index idx_v on VARIANT column v` |
| `DROP INDEX idx_s ON t PARTITION (p1)` (STRING control) | Job `FINISHED`;
`.idx` 13411 -> 9865 bytes; a MATCH on `s` in p1 fails with `match_any not
support execute_match` | Not changed |
### Details
- **Frequency:** Always, for DROP INDEX ON PARTITION on an inverted index of
a VARIANT column in shared-nothing mode.
- **Root cause:** The FE accepts the statement for every inverted index.
`IndexBuilder::update_inverted_index_info()` looks up the indexes to drop with
`TabletSchema::inverted_indexs(column)` for the column named in the job, and
for a root VARIANT column that function returns only VARIANT values indexes.
With nothing found, the rowset is rewritten with every index file copied and
the job finishes.
- **Why existing tests missed it:** Unit tests: the partition drop tests in
`IndexChangeJobTest` (`testDropIndexOnPartition*`) use a table without VARIANT
columns and check only what the FE accepts. Regression:
`inverted_index_p0/index_change/test_drop_index_on_partition` drops indexes on
`varchar` and `string` columns only, and checks the job state and `SHOW INDEX`,
not whether a partition still uses the index.
- **Fix:** `SchemaChangeHandler` rejects the partition drop when a column of
the index is VARIANT, beside the other checks of that path and in line with the
BUILD INDEX check on VARIANT columns. Making the BE drop the subcolumn indexes
would change the rowset rewrite for V2 and SNII index files and is left out;
DROP INDEX on the whole table still removes these indexes.
- **Behavior change:** Both statement forms now fail for an inverted index
of a VARIANT column, also with IF EXISTS when the index exists.
- **Other paths and branches:** BUILD INDEX already rejects VARIANT columns,
and VARIANT values indexes were already rejected with their own message. Cloud
mode: #71041 rejects every partition drop; until it is merged, this check
applies there too. `branch-4.1` has the bug since #70357; on `branch-4.2` the
feature arrives with #70352, which will carry this fix.
### Testing
-
`SchemaChangeHandlerTest#testDropIndexOnPartitionRejectsVariantColumnIndexes`
(new): on a partitioned table with a root VARIANT index, a `field_pattern`
index and a STRING index, checks that the two VARIANT partition drops are
rejected without creating an index change job, and that the STRING one is
accepted. On master without the fix it failed with `Expected
java.lang.Exception to be thrown, but nothing was thrown`. With the fix,
`SchemaChangeHandlerTest`, `IndexChangeJobTest`, `CloudIndexTest`,
`VariantValuesIndexChangeTest` and `CloudSchemaChangeHandlerTest` pass locally.
- `test_drop_index_on_partition` case 11 (new), run locally against a
shared-nothing docker cluster: with the master FE it fails with `Expect
exception msg contains 'DROP INDEX ON PARTITION is not supported for index
idx_v on VARIANT column v', but meet 'null'`; with the fixed FE both statements
fail with the new message and the whole suite passes.
- The reproduction above ran on a shared-nothing docker cluster built from
master of 2026-11-25.
### Release note
DROP INDEX ... ON PARTITION now fails with "DROP INDEX ON PARTITION is not
supported for index <index> on VARIANT column <column>" for inverted indexes on
VARIANT columns. Before, it reported success but kept the index on the named
partitions. Drop the index from the whole table instead.
### Check List (For Author)
- Behavior changed: Yes (see Details)
- Does this need documentation: No. The DROP INDEX page in
apache/doris-website does not document the ON PARTITION form yet; when it does,
it should state this limitation.
- Pre-submission status: Ready
### AI Disclosure
- Tool: Claude Code (Claude Opus 5.5)
- Generated: the fix, the tests, the reproduction script, and this
description
- Human review: not stated
- Prompts: The author had the agent watch #70352, fix its review findings on
master first, and then pick the fixes to the release branches.
--
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]