Skip to content

[fix](orc) Advance past SARG-filtered stripe suffixes when seeking - #431

Merged
Gabriel39 merged 1 commit into
apache:orcfrom
Gabriel39:fix/orc-seek-filtered-stripe
Nov 3, 2026
Merged

Gabriel39 merged 1 commit into
apache:orcfrom
Gabriel39:fix/orc-seek-filtered-stripe

Conversation

@Gabriel39

Copy link
Copy Markdown

Problem

On an initialized stripe, seekToRow() can receive the stripe-end sentinel when SARG rejects the target and every remaining row group. Treating the sentinel as a row-group index accesses past RowIndex entries for an exact index boundary. A partial final group can also cause a premature EOF before later matching stripes. Doris condition-cache granule seeks can trigger this boundary.

Change

Initialize the next selected stripe before positioning its column readers, respecting the configured stripe range and EOF. This follows the same initialization path as a fresh seek.

Tests

  • Add 32 cases covering exact/partial row groups, fresh/initialized stripes, lazy/non-lazy reads, skipped middle stripes, restricted ranges, EOF and backward seeks.
  • All 16 initialized-stripe cases fail with the original reader; all 32 new cases pass with the fix.
  • 56 focused ORC reader and predicate-pushdown tests pass under AddressSanitizer.
  • clang-format 16 checks pass.

When seekToRow advances beyond every selected row group of an initialized
stripe, the returned row offset is the stripe-end sentinel. Treating it as
a row-group index can access past RowIndex entries or prematurely stop
reading a partially filled final row group.

Initialize the next selected stripe, respecting the configured stripe range,
before positioning column readers. Add 32 cases covering initialized and
fresh seeks, exact and partial index groups, lazy followers, filtered
intermediate stripes, split boundaries, EOF and backward seeks.

Validation: 56 focused ORC reader and predicate-pushdown tests passed under
AddressSanitizer. All 16 initialized-stripe cases fail without the fix;
all 32 new cases pass with it. clang-format 16 checks passed.
@Gabriel39
Gabriel39 merged commit 7955b00 into apache:orc Nov 3, 2026
Gabriel39 added a commit to apache/doris that referenced this pull request Nov 4, 2026
…#70079)

### What problem does this PR solve?

Related PR: apache/doris-thirdparty#431 (merge
the ORC dependency fix first)

A condition-cache granule can start in a stripe's SARG-filtered suffix
while containing a matching row in the next stripe. On an initialized
stripe, ORC's `seekToRow()` uses the stripe-end sentinel as a row-group
index. This can access past the index when the stripe ends on an index
boundary, or prematurely return EOF when the last row group is partial.

The same-stripe fast path originates in [Apache ORC
ORC-1170](apache/orc#1114); the same missing
stripe-end handling remains in the current upstream C++ reader.

Pin the ORC fix that initializes the next selected stripe before
positioning its column readers. Preserve SARG pruning, lazy reads and
split boundaries.

Add a Doris reader regression and a 1.5 KB synthetic ORC fixture with
its generator. The fixture has two 20,000-row stripes, a 10,000-row
index stride, and one matching row at the start of each stripe. A cache
hit seeks to row 18,432 in the first stripe's filtered suffix. The SQL
regression compares cache-disabled and cached results with lazy reads
and min/max pruning enabled or disabled, and checks the profile for
actual cache hits and skipped rows.

### Release note

Fix potential crashes and missing rows when ORC condition-cache seeks
reach a SARG-filtered stripe suffix.

### Check List (For Author)

- Test:
- [x] Unit Test: 247 ORC-related BE tests passed under AddressSanitizer,
including the new Doris condition-cache case and 32 dependency boundary
cases.
- [x] Unit Test: 56 focused standalone ORC tests passed under
AddressSanitizer. Reverting the fix makes all 16 initialized-stripe
boundary cases fail.
- [ ] Regression test: SQL suite added; Groovy compilation checked. The
external SQL suite has not been executed locally.
  - [x] clang-format 16 and BE build-hygiene checks passed.
- [ ] Local full-file clang-tidy analysis did not complete within ten
minutes; no completed result is available.
- Behavior changed:
  - [x] Yes. Safely advance to the next matching stripe or EOF.
- Does this need documentation?
  - [x] No.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant