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

   ### Background
   
   The native ORC reader can answer MIN/MAX from selected stripe statistics 
instead of decoding rows. ORC floating statistics also contain an optional sum, 
which standard writers make NaN when a stripe contains a NaN.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: #65183 (introduced native ORC metadata aggregates), #65559 (4.1 
backport)
   PR Type: Bugfix
   
   Problem Summary:
   
   An ORC stripe containing `[1, NaN, 2]` can expose finite bounds, so metadata 
aggregation returns `2` while an ordinary scan returns `NaN`. Require an 
available, finite sum before trusting floating bounds and otherwise use the 
existing row-scan fallback. Most of the diff adds tests for the fallback and 
the finite-value optimization.
   
   | FLOAT and DOUBLE values | MAX before | MAX after / ordinary scan |
   |---|---|---|
   | `1, NaN, 2` | `2` | `NaN` |
   
   ### Details
   
   - **Change map:** Production code +4/-1 lines; tests +644/-2; generated 
regression output +85/-0; no documentation changes. The production change is 
one statistics eligibility guard; the tests author standard ORC files and 
exercise reader fallback, selected stripes and SQL aggregates.
   - **Frequency:** Always when native MIN/MAX uses finite floating bounds from 
a selected stripe whose values contain a hidden NaN; reproduced with both FLOAT 
and DOUBLE using standard writers.
   - **Root cause:** `set_floating_zone_map` accepted minimum and maximum 
without checking the sum. A writer can keep finite endpoints after observing a 
NaN, so those endpoints do not preserve row aggregation semantics.
   - **Why existing tests missed it:** Existing 
`NewOrcReaderTest.AggregatePushdown*` tests cover primitive and nested bounds, 
stripe selection, timestamps and COUNT without floating NaNs. Iceberg 
regressions such as `test_iceberg_orc_decimal_bounds` check decimal metadata 
rather than floating MIN/MAX; fuzzy floating comparisons can also miss a NaN 
mismatch. New SQL tests compare strings and NaN flags explicitly.
   - **Fix:** Reject missing or non-finite floating sums at native metadata 
conversion. This conservatively scans infinities and sum overflows as well, 
while finite sums retain metadata aggregation. COUNT, integer bounds and 
ordinary ORC predicate pruning retain their existing behavior.
   - **Other paths and branches:** The conversion is shared by native ORC 
catalog scans, including Iceberg and Hive. It has one aggregate call site; 
ordinary ORC SARG pruning uses the SDK separately. Parquet metadata aggregation 
uses a separate implementation. Static inspection finds the same unchecked 
guard in branch-4.1 and branch-4.2; branch-3.1 and branch-4.0 lack this native 
path. Release branches were not executed locally.
   
   ### Testing
   
   - Local ASAN: all 201 `NewOrcReaderTest` tests passed. Four new tests cover 
24 floating-statistics inputs, real `TableReader` fallback without losing NaNs 
or rows, valid missing-sum compatibility files, and safe/unsafe stripe 
selection and pruning. The new cases fail against the original guard.
   - Local native SQL: `test_iceberg_orc_floating_minmax` fails before the fix 
(`2` versus `NaN`) and passes after it. Fourteen standard SDK fixtures cover 
NaN positions, NULLs, infinities, overflow, independent FLOAT/DOUBLE columns 
and empty tables. Generated output was independently checked against scan 
results and known fixture counts, then replayed normally.
   - The fixture helper authored and read back all 14 cases with Iceberg 1.12 
and the stock 1.10.1 runtime SDK. No data or statistics editing is used for the 
NaN reproduction.
   
   ### Notes for Reviewers
   
   The missing-sum unit fixture only renames an optional protobuf field while 
preserving bounds and data; it tests compatibility separately from 
standard-writer NaNs. The SQL suite supports an existing Spark/REST Docker 
environment or an explicitly configured local SDK/file warehouse. Docker 
deployment and automatic Docker CI execution were not verified locally.
   
   ### Release note
   
   Fix incorrect floating MIN/MAX results from ORC stripe metadata when a 
stripe contains NaN values.
   
   ### Check List (For Author)
   
   - Behavior changed: No
   - Does this need documentation: No
   - Pre-submission status: Partially verified: Docker deployment and automatic 
Docker CI execution are unverified; the same SQL suite passed on an owned local 
cluster
   
   ### AI Disclosure
   
   - Tool: Codex (GPT-6)
   - Generated: Code, unit tests, regression tests and this description
   - Human review: not stated
   


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