Gabriel39 opened a new pull request, #70862:
URL: https://github.com/apache/doris/pull/70862

   ### Background
   
   Doris translates supported ORC scan predicates into search arguments. The 
ORC library uses file statistics and Bloom filters to skip stripes or row 
groups before Doris evaluates SQL predicates on the remaining rows.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: #65183 (introduced the current SARG builder; the legacy path was 
already affected)
   PR Type: Bugfix
   
   Problem Summary:
   
   ORC scans with floating-point Bloom filters can omit matching rows when a 
zero predicate and stored zeros have opposite signs. This change probes both 
zero bit patterns in one IN leaf so pruning preserves SQL's equality of 
positive and negative zero. Most of the diff adds real-file unit and SQL 
regression coverage.
   
   For the checked-in row-group fixture, a count with `WHERE d = 0.0` and SARG 
enabled produced:
   
   | Before | After | Expected |
   | --- | --- | --- |
   | 1000 | 2000 | 2000 |
   
   ### Details
   
   - **Change map:** Production code +22/-11; tests and fixture generator 
+403/-0; generated regression output +13/-0; documentation +0/-0. Two ORC 
fixtures total 132,252 bytes. Tests account for most of the change.
   - **Frequency:** Always in the reproduced layout: zero signs occupy 
different Bloom filters, and pruning probes only the opposite sign. It affects 
FLOAT and DOUBLE equality, null-safe equality and IN predicates.
   - **Root cause:** ORC Bloom filters hash the raw floating-point bits, while 
SQL equates both signs of zero. The SARG builder previously supplied only the 
literal's sign, allowing a matching group to be rejected before row filtering.
   - **Why existing tests missed it:** 
`NewOrcReaderTest.SargFloatWideningCastConjunctPrunesStripes` covers floating 
ranges without signed-zero Bloom filters, while the binary Bloom tests cover 
strings. The closest SQL suite, `test_orc_condition_cache_seek`, covers integer 
seek/cache behavior. Neither layer tests opposite-sign zero groups. The new SQL 
suite is in the External pipeline's `p0,external` group.
   - **Fix:** Normalize zero equality and IN candidates at the shared Doris 
SARG adapter by adding the opposite sign to one IN leaf. ORC merges separate 
equality leaves for the two signs, so an OR of equalities would still be 
unsafe. Nonzero equality and IN Bloom pruning remain covered.
   - **Other paths and branches:** This fixes the native ORC SARG path shared 
by TVFs and catalogs on master. Parquet uses a separate implementation. Static 
checks found the same defect in branch-3.1, branch-4.0, branch-4.1 and 
branch-4.2; those need separate backports, including legacy reader paths where 
present. Release branches were not dynamically tested. #65183 introduced the 
current builder, not the original defect.
   
   ### Testing
   
   - Locally ran 20 new parameterized real-ORC tests across FLOAT/DOUBLE and 
row-group/stripe layouts. Before the fix, 12 equality/IN tests failed and eight 
controls passed; after it, all 20 passed. Together with the existing 
`NewOrcReaderTest` suite, all 217 ASAN tests passed.
   - Locally ran `run-regression-test.sh --run -d external_table_p0/tvf -s 
test_orc_signed_zero_bloom`, after generating output through the runner. All 
336 complete ordered-ID comparisons passed with SARG and lazy materialization 
each on/off, both column widths and both layouts; one suite, zero failures and 
zero skips. The baseline failed by losing the negative-zero IDs.
   - Regenerated both fixtures byte-for-byte and independently decoded their 
zero signs, NULLs and stripe layouts with PyArrow.
   
   ### Notes for Reviewers
   
   SQL regression ran against a disposable local S3 emulator. Provider-specific 
remote S3 and Azure uploads were not exercised locally; the suite follows the 
existing provider-aware upload and cleanup pattern.
   
   ### Release note
   
   Fix missing rows in ORC scans when floating-point Bloom pruning encounters 
equality or IN predicates involving positive and negative zero.
   
   ### Check List (For Author)
   
   - Behavior changed: No
   - Does this need documentation: No
   - Pre-submission status: Ready
   
   ### AI Disclosure
   
   - Tool: Codex (GPT-6)
   - Generated: Code, unit tests, regression tests, fixture generator and this 
description.
   - Human review: Not stated by the author.
   


-- 
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]

Reply via email to