airborne12 opened a new pull request, #71230: URL: https://github.com/apache/doris/pull/71230
### Background Light schema change adds a column to the table schema while retaining existing segments. When a segment predates the column, the segment reader supplies the column default for its rows. `BUILD INDEX` creates the requested inverted index for existing local rowsets. ### What problem does this PR solve? Issue Number: None Related PR: #32550 (added the missing-column guard) PR Type: Bugfix Problem Summary: A `BUILD INDEX` job can finish after skipping historical segments that lack the indexed column. For example, load two rows, add a nullable text column, build its inverted index, and insert row 3 with the value `searchable`. A query with `multi_match(new_text, 'any', 'searchable')` can report `only inverted index queries are supported`. With this change, it returns row 3. A non-NULL column default is also searchable on the historical rows. ### Details - **Frequency:** Always for the local reproduction with automatic compaction disabled and a historical rowset that predates the column. - **Root cause:** `IndexBuilder` resolves the target column against the old rowset schema, so it skips an index whose column was added later. The constant column reader also needs to open the resulting index because the segment still lacks physical pages for the column. - **Why existing tests missed it:** `IndexBuilderTest.NonExistentColumnIndexTest` exercises a column absent from the build request schema as well as the rowset. `MissingIndexedColumnUsesDefaultWithoutPhysicalIndex` covers the scan before an index file exists. `test_index_change_on_new_column` checks metadata and uses `MATCH`, which can evaluate the historical NULL default without an index. - **Fix:** Use the column unique ID to bind the index and take its definition from the build task schema when the rowset lacks the column. Feed the existing default-value reader into the index writer and retain the segment files and row IDs. The build reads column data without opening unfinished index files. Queries can open the finished index through the constant column reader. - **Other paths and branches:** The fix covers the shared-nothing index builder, with V2 and SNII exercised locally. Remote rowsets use a separate selection path. The rowset-schema-only lookup is also present on the inspected 3.1, 4.0, 4.1, and 4.2 branches. - **Behavior change:** After a successful local build, index-only queries can use the built index for historical rows whose column value comes from the schema default. ### Testing - Ran the same suite on the unmodified `master` build at `7a10e10b5dc`. Both index jobs finished, then the first `multi_match` query failed with `only inverted index queries are supported`. - Built the BE with ASAN and built the FE with the Huawei OBS dependency profile disabled for the local cluster. - Ran `test_build_index_on_added_column` on V2 and SNII. Both formats returned the new matching row for `multi_match` and `SEARCH`, the historical rows for the non-NULL default, and the same results for the index created before the schema change. - Passed `test_index_change_on_new_column`, `test_index_change_4`, `test_index_change_5`, and `test_add_drop_index_with_delete_data` on the same cluster. - Passed the repository header hygiene, clang-format 16, and changed-line clang-tidy checks. ### Release note After upgrading the BE, run `BUILD INDEX` to index historical rows for a column added through light schema change, including rows whose value comes from the column default. ### Check List (For Author) - Behavior changed: Yes (see Details) - Does this need documentation: No - Pre-submission status: Ready ### AI Disclosure - Tool: Codex (GPT-6.2 Sol) - Generated: Production code, regression suite, and description - Human review: Pending -- 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]
