Skip to content

[core] Prune merged Data Evolution reads with Parquet statistics - #1469

Open
SteNicholas wants to merge 2 commits into
apache:mainfrom
SteNicholas:PAIMON-1445
Open

SteNicholas wants to merge 2 commits into
apache:mainfrom
SteNicholas:PAIMON-1445

Conversation

@SteNicholas

@SteNicholas SteNicholas commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Purpose

Closes #1445.

Selective filters can leave a Data Evolution merge decoding entire column files. Use Parquet statistics from the current column providers to build a shared row-ID selection and keep values aligned across files with different page boundaries.

Brief change log

  • Resolve current providers by stable field ID, historical schema, and file version. Use row-group and page statistics for each conjunct whose fields come from the same provider.
  • Intersect candidates with caller ranges and file-index hits, exclude deleted rows, and read the same positions from each provider. Apply the full predicate to the reconstructed rows before LIMIT.
  • Reuse Parquet metadata, validate page spans and projected page row counts, and retry failed indexed reads from whole column chunks. Ignore statistics with inconsistent NULL counts.
  • Keep the offset-only path for predicate-free sparse reads. When a selected span fits in one row group, check footer statistics first and skip the ColumnIndex if the footer proves that every row matches or none can match. If an optional ColumnIndex fails to decode, retry the OffsetIndex using the metadata bytes already fetched.

Tests

  • Rust 1.98.0 passed 5,112 core unit tests and 59 targeted integration tests. Eight core tests are ignored by default. cargo fmt --all -- --check and git diff --check passed.
  • With a 100,000-row, 49-column predicate file and 64 rows per page, sparse matching reads return the same rows and read the same column-data and total bytes with pushdown enabled or disabled. The regression also covers a narrow fixture with one-row pages and verifies that a footer-rejected selection decodes no rows. Sparse-read I/O regression
  • Regressions cover projected page alignment, damaged indexes and file errors, and inconsistent NULL counts.

Benchmark

Both settings returned identical results. The table reports medians from seven runs with alternating execution order and the shared metadata cache disabled.

Filter Rows sent to merge, off → on Column-data bytes, off → on Total bytes, off → on Median time, off → on
Selective (1 result) 524,288 → 128 2,342,012 → 3,595 3,390,588 → 1,157,808 49.65 → 15.71 ms
Full range (262,144 results) 524,288 → 524,288 2,342,012 → 2,342,012 3,390,588 → 3,390,588 57.92 → 62.08 ms

API and Format

The Java-compatible data-evolution.merged-read.stats-pushdown.enabled option defaults to true. It applies to row-tracked, unbucketed Data Evolution append tables whose ordinary Parquet files share a complete row-ID range. Both settings read the existing storage format.

Documentation

🤖 Assisted with Codex.

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shared row ranges have end-to-end value. The earlier undersized-page case now falls back. Locally, 46 integration tests, eight candidate-range cases and 102 Parquet tests passed. The selective benchmark returned the same row and reduced column data reads from 2,342,012 bytes to 756. Two additional probes exposed the cases below.

@SteNicholas
SteNicholas force-pushed the PAIMON-1445 branch 2 times, most recently from b6d1080 to 789b8d6 Compare November 22, 2026 05:52
@SteNicholas SteNicholas changed the title [core] Prune merged Data Evolution reads with shared row-ID ranges [core] Prune merged Data Evolution reads with Parquet statistics Nov 22, 2026
@SteNicholas

Copy link
Copy Markdown
Member Author

@JingsongLi, I reran the four regression tests for the cases you reported after rebasing 05bb9b71 onto main. All four passed on the current head. Commit 51374832

  • With id >= 0 and only _ROW_ID = 102117 requested, statistics rule out no rows, so the reader keeps the cached OffsetIndex. Pushdown on and off both return (id=2117, _ROW_ID=102117) and read the same number of column-data bytes, less than a full chunk. Sparse-read regression
  • When statistics do produce candidates, projected page boundaries still need independent row counts, even if the caller already selected exactly those rows. Without those counts the reader decodes whole chunks. Your rating = 36 case returns (id=36, _ROW_ID=100036). Projected-row regression
  • Predicate-free sparse reads request only the OffsetIndex. When both indexes are optional and the ColumnIndex fails to decode, the reader retries the offsets using metadata bytes it already fetched. Index-loading regression
  • Indexed data pages must be contiguous and the final page must end at the chunk boundary. With the last page recorded one byte short, the reader falls back to the full chunk and rating = 4095 still returns the last row. Page-span regression

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shared Parquet statistics can reduce the work needed for selective Data Evolution reads. The merged-reader and Parquet suites passed locally on aaa35f6f, and the earlier offset-only fallback preserved data-page reads in the new probe. I reproduced a separate cold-read I/O regression below.

@SteNicholas
SteNicholas force-pushed the PAIMON-1445 branch 2 times, most recently from edc2753 to 03980db Compare November 23, 2026 19:28
@SteNicholas

Copy link
Copy Markdown
Member Author

Thanks for checking the earlier fallback and reproducing the cold-read regression. The force-pushed commit keeps sparse reads on the OffsetIndex path when row-group footer statistics can decide the predicate. The regression checks that pushdown on and off return the same rows and read the same column-data and total bytes on both the wide and narrow fixtures. Review · Commit 03980db2 · Regression

The same commit updates Parquet to 59.3.3 and refreshes the dependency reports. The dependency policy, dependency report verification, and release license checks pass locally. RustSec advisory

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shared selection has end-to-end value for selective merged reads. The full core suite passed 5,112 tests locally. The earlier footer-decidable sparse reads, page alignment and optional-index fallback cases pass on this head. An additional counting-I/O test reproduced the point-read regression below.

@SteNicholas

Copy link
Copy Markdown
Member Author

Thanks for rerunning the core suite and reproducing the point-read regression, @JingsongLi. The follow-up keeps a single selected row on the OffsetIndex path when the row-group footer is inconclusive and lets the merged residual evaluate that row. A footer that rules out the row still skips decoding.

On the 100,000-row fixture with a 49-column rating provider, _ROW_ID = 102117 returns the expected row for rating >= 2117 and no rows for rating >= 2118. Both cases read the same data-page and total bytes with pushdown on and off. The core suite passed 5,113 tests, with 8 ignored. Review · Commit 942195a3 · Regression test

Selective filters can leave a Data Evolution merge decoding entire
column files. Column updates can leave stale values in older files,
and Parquet pages can start at different rows across providers. A
shared row-ID selection keeps the current values aligned during the
merge.

- Prune row groups and pages with statistics from the current provider
  of every field in a conjunct, addressing apache#1445.
- Intersect candidates with caller ranges and bitmap hits, exclude
  deleted rows, and apply the full filter to reconstructed rows
  before LIMIT.
- Reuse Parquet metadata and validate projected page row counts. Skip
  column indexes when footer statistics settle a sparse selection,
  and retry failed indexed reads from whole column chunks.
- Enable pruning by default for row-tracked, unbucketed Data Evolution
  tables using Java's data-evolution.merged-read.stats-pushdown.enabled
  option. Benchmark selective and full-range reads.
Use the existing sparse read and merged residual for a single selected row when its Parquet row-group statistics are inconclusive. Loading the entire ColumnIndex for a point can cost more than reading the selected pages.

Cover matching and rejected points with cold I/O assertions for both data-page and total bytes.
@SteNicholas

Copy link
Copy Markdown
Member Author

Ping @JingsongLi.

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shared selection has end-to-end value. On 1646549b integrated with ebcff9f1, 39 table integration tests and 14 candidate-selection tests passed. The local cold-metadata selective benchmark returned the same result and reduced total reads from 3,390,588 to 1,157,808 bytes. Two additional read cases reproduced the issues below.

winning_ids.contains(&field.id())
&& supports_stats(field.data_type())
&& !self.partition_fields.iter().any(|p| p.id() == field.id())
&& stats_evolution_is_safe(file_fields[i].data_type(), field.data_type())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Use the effective read type when deciding whether bounds can prune. I read a merged Parquet split containing rating INT = 2117 through with_read_type with the same field ID projected as TINYINT, and applied the table predicate rating = 69. With merged statistics disabled, the normal reader narrows 2117 to 69 and returns row 2117. With the new pruning enabled, the scan returns no rows. The statistics check compares the physical field with the table field and skips the non-order-preserving conversion to the actual provider read type. Bypass stats for predicates on a field whose effective read conversion can change the comparison, and cover explicit read types in the merged-split regression.

// For a single selected row, read its pages with the OffsetIndex and
// let the merged residual filter decide whether the row matches.
RowGroupMatch::Unknown => {
!indexed_selection.is_some_and(|filter| filter.span.from() == filter.span.to())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Keep offset-only I/O for a tiny range inside one data page. On the 100,000-row fixture with 49 rating-provider columns and 64 rows per page, I explicitly selected rows 2117–2118 and filtered rating >= 2117. Both rows survived with pruning on and off. The enabled read fetched 3,159,015 bytes versus 1,939,935 bytes, and column-data reads rose from 450 to 3,595 bytes. The inconclusive-footer fallback only handles exactly one row, even when both selected rows fit on one page. Consider the selection and index costs before fetching the ColumnIndex, and let the residual check a tiny selected range.

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.

[Improvement] Prune Data Evolution merged reads using shared candidate row ranges

2 participants