guptashivam04 opened a new pull request, #70849:
URL: https://github.com/apache/doris/pull/70849
### What problem does this PR solve?
Issue Number: None
Related PR: #70668 (split from it)
PR Type: Bug fix
Problem Summary:
```sql
SELECT count(*) FROM t WHERE s MATCH 'true' AND CAST(s AS BOOLEAN)
```
returns 0 with the inverted index on, and the matching rows with it off (or
with `enable_no_need_read_data_opt = false`). The same happens with SEARCH,
MATCH_ANY and IN in place of MATCH.
`SegmentIterator` does not read a column's data pages when the index has
answered every filter on it and the column is not selected. It records the
filters on a column by the expression node each slot sits under. A conjunct
that is the column itself or a cast of it has no such node, so it was never
recorded. Once the index answered `s MATCH 'true'`, `s` looked fully answered,
was skipped, and `CAST(s AS BOOLEAN)` ran on empty values.
### What is changed?
In `_calculate_common_expr_index_exec_status`, a conjunct whose root is a
slot or a cast of a slot is recorded as not answered by the index, so the
column is read.
### Release note
Fix a filter that only casts a column, such as `CAST(s AS BOOLEAN)`,
returning no rows when the inverted index answers another filter on the same
column.
### Check List (For Author)
- Test
- [x] Regression test
- `inverted_index_p0/test_index_cast_root_conjunct`: MATCH,
MATCH_ANY, NOT and IN next to a cast of the same column, with the index on and
off, the column selected and not; SEARCH against the MATCH rows. The `.out` is
generated, and index-on and index-off blocks are identical. Fails without this
change (0 rows instead of 129).
- `inverted_index_p0` and `search` (298 suites) pass, except 13 that
fail the same way without this change on the same machine (custom analyzer
dictionaries, replica setup, and index policies left over from earlier local
runs).
- [ ] Unit Test
- Behavior changed: Yes. Such queries now return the matching rows.
- 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]