Guptak12 opened a new pull request, #68796:
URL: https://github.com/apache/doris/pull/68796
### What problem does this PR solve?
Issue Number: close #68715
Related PR: None
Problem Summary:
BKD indexes preserve the IEEE-754 distinction between negative and positive
floating-point zero in their encoded byte order. Doris SQL comparison
semantics, however, treat `-0.0` and `+0.0` as equal.
Consequently, indexed `FLOAT` and `DOUBLE` predicates could return different
results from a normal column scan:
- `v = 0` and `v >= 0` omitted rows containing `-0.0`.
- `v < 0` and `v != 0` incorrectly included rows containing `-0.0`.
This change represents SQL zero as the closed BKD interval `[-0.0, +0.0]` at
query time and selects the appropriate lower or upper bound for each inclusive
or exclusive comparison.
The change applies to both the legacy BKD reader and the SNII reader. It
does not modify the on-disk key encoding, so existing indexes remain compatible.
### Release note
Fix incorrect inverted-index results for `FLOAT` and `DOUBLE` comparisons
involving negative and positive zero.
### Check List (For Author)
- Test
- [ ] Regression test
- [x] Unit Test
- [x] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason
#### Unit-test validation
Built the ASAN BE unit-test executable and ran six focused tests covering:
- Legacy BKD `FLOAT` and `DOUBLE` range queries.
- SNII query-bound construction.
- SNII `FLOAT` and `DOUBLE` reader behavior.
- Query values expressed as both `-0.0` and `+0.0`.
- `=`, `<`, `<=`, `>`, and `>=` comparisons.
All six focused tests passed.
#### Manual validation
1. Built and started one FE and one BE from the PR commit on macOS arm64.
2. Created a V3 inverted-index table containing `-1.5`, `-0.0`, `+0.0`, and
`+1.5` in both `FLOAT` and `DOUBLE` columns.
3. Forced the inverted-index query path:
```sql
SET enable_inverted_index_query = true;
SET enable_inverted_index_query_cache = false;
SET inverted_index_skip_threshold = 0;
```
4. Verified these results for both `FLOAT` and `DOUBLE`:
| Predicate | Matching row keys |
| --------- | ----------------- |
| `v = 0` | `0, 1` |
| `v < 0` | `3` |
| `v <= 0` | `0, 1, 3` |
| `v > 0` | `2` |
| `v >= 0` | `0, 1, 2` |
| `v != 0` | `2, 3` |
5. Disabled inverted-index queries and confirmed that the normal scan
returned the same results.
Additional validation:
- Full FE and BE production build succeeded.
- Doris clang-format 16 check passed.
- Build-hygiene checks passed.
- No new changed-line clang-tidy findings were identified.
- Behavior changed:
- [ ] No.
- [x] Yes. Indexed `FLOAT` and `DOUBLE` predicates now treat `-0.0` and
`+0.0` as equal, matching normal Doris SQL comparison semantics.
- Does this need documentation?
- [x] No.
- [ ] Yes.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
--
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]