airborne12 opened a new pull request, #63637:
URL: https://github.com/apache/doris/pull/63637
## Proposed changes
Issue Number: close #N/A (Jira CIR-20006)
### What problem does this PR solve?
SEARCH (Lucene syntax) predicates against columns that have no inverted
index silently fall back to an empty bitmap on BE (`vsearch.cpp` and
`function_search.cpp` only log a WARNING then `return Status::OK()` with an
empty result), making the query look like *no rows matched*. That is
indistinguishable from a successful query that simply found nothing and
misleads users.
This PR adds a planning-time check in `RewriteSearchToSlots`, matching the
existing "column does not exist" behavior — fail fast with a clear
`AnalysisException` instead of letting BE silently return FALSE.
- **Normal columns**: require `OlapTable.getInvertedIndex(column, null) !=
null`.
- **Variant subcolumns** (`parent.path`): require any `INVERTED` index whose
first column equals the parent variant column; the concrete subcolumn binding
is still resolved per-segment in BE, consistent with the `is_variant_sub`
branch in `function_search.cpp`.
Also hardens `OlapTable.getInvertedIndex` against NPE when the table has no
`TableIndexes` set (returns `null` instead of dereferencing).
Error message example:
```
Field 'msg_body' has no inverted index, cannot be used in search:
msg_body:error.
Create an inverted index on the column first (ALTER TABLE ... ADD INDEX ...
USING INVERTED).
```
### Release note
SEARCH() with Lucene syntax now throws `AnalysisException` at planning time
when the referenced column has no inverted index, with guidance to add one via
`ALTER TABLE ... ADD INDEX ... USING INVERTED`. Previously such queries
silently returned zero rows.
### Check List (For Author)
- [x] Test: Unit Test
- `RewriteSearchToSlotsTest` updated and extended:
- `testRewriteSearchThrowsWhenColumnHasNoInvertedIndex` (new) — column
exists but has no inverted index → throws `AnalysisException` mentioning
`inverted index`.
- `testRewriteSearchSucceedsWhenColumnHasInvertedIndex` (new) — column
with `IndexType.INVERTED` rewrites to `SearchExpression`.
- `testRewriteSearchHandlesCaseInsensitiveField` (updated) — now uses a
table copy with an inverted index on `name`.
- [x] Behavior changed: Yes — previously silent FALSE now becomes a clear
`AnalysisException` at planning time. The previous behavior was itself a
usability bug.
- [x] Does this need documentation: No
--
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]