Skip to content

fix: handle non-contiguous RowRanges when resolving global row IDs#383

Merged
lxy-9602 merged 44 commits into
alibaba:mainfrom
zhf999:fix-rowid
Jul 2, 2026
Merged

fix: handle non-contiguous RowRanges when resolving global row IDs#383
lxy-9602 merged 44 commits into
alibaba:mainfrom
zhf999:fix-rowid

Conversation

@zhf999

@zhf999 zhf999 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Purpose

  • Fix a correctness bug where upper layers assumed returned batch rows are continuous and derived file row IDs as previous_batch_start + offset.
  • Introduce unified usage of GetPreviousBatchFileRowId(batch_row_id) to resolve the file row ID for a row index inside the current batch.
  • In PrefetchFileBatchReaderImpl, cache the actual file row IDs for each returned batch and keep row-id mapping aligned when a batch is sliced by read_range.
  • For Parquet, add target row-range union and per-batch row mapping logic:
    • Merge filtered target ranges into a file target row set.
    • Build batch_row_id -> file_row_id mapping in NextBatch().
    • Keep GetPreviousBatchFileRowId() correct under non-contiguous rows caused by predicate + bitmap filtering.
  • Update upper-layer consumers to query per-row file IDs directly (deletion vectors, bitmap index filtering, _ROW_ID field conversion, KeyValue iteration positions).

Tests

  • Updated and adapted reader tests to the new interface and semantics:
    • src/paimon/format/avro/avro_file_batch_reader_test.cpp
    • src/paimon/format/blob/blob_file_batch_reader_test.cpp
    • src/paimon/format/lance/lance_format_reader_writer_test.cpp
    • src/paimon/format/orc/orc_file_batch_reader_test.cpp
    • src/paimon/format/parquet/parquet_file_batch_reader_test.cpp
    • src/paimon/common/reader/prefetch_file_batch_reader_impl_test.cpp
  • Added/extended coverage in Parquet with TestRowMapping to validate file row mapping across non-contiguous ranges.
  • Remaining changes are interface migration plus consistency updates of call sites and assertions.

API and Format

  • Public reader API change: FileBatchReader and implementations now use GetPreviousBatchFileRowId(uint64_t batch_row_id).
  • Semantic change: returns the file row ID for the batch_row_id inside the current batch (instead of deriving by batch start + offset under contiguous assumptions).
  • Storage format and on-disk protocol are unchanged.

Documentation

No.

Generative AI tooling

gpt-5.3-codex

Copilot AI review requested due to automatic review settings June 26, 2026 02:55

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment thread include/paimon/reader/file_batch_reader.h
Comment thread src/paimon/common/reader/prefetch_file_batch_reader_impl.cpp
Comment thread src/paimon/common/reader/prefetch_file_batch_reader_impl_test.cpp Outdated
Comment thread src/paimon/common/reader/prefetch_file_batch_reader_impl_test.cpp
Comment thread src/paimon/core/io/complete_row_tracking_fields_reader.cpp
Comment thread src/paimon/testing/mock/mock_file_batch_reader.h
Comment thread src/paimon/testing/utils/read_result_collector.h Outdated
Comment thread src/paimon/testing/utils/read_result_collector.h
Comment thread src/paimon/format/parquet/parquet_file_batch_reader.cpp
Comment thread src/paimon/format/orc/orc_file_batch_reader_test.cpp Outdated
Comment thread src/paimon/testing/utils/read_result_collector.h
Comment thread src/paimon/format/parquet/parquet_file_batch_reader.h
Comment thread src/paimon/format/parquet/parquet_file_batch_reader.cpp
Comment thread src/paimon/common/reader/prefetch_file_batch_reader_impl_test.cpp Outdated
Comment thread include/paimon/reader/file_batch_reader.h
@zhf999
zhf999 requested review from lxy-9602 and zjw1111 June 30, 2026 14:50

@zjw1111 zjw1111 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the well-structured fix! The approach of replacing GetPreviousBatchFirstRowNumber() with per-row GetPreviousBatchFileRowId(batch_row_id) is a clean solution to the non-contiguous row problem under page-level predicate pushdown. The Parquet GenerateRowMapping logic correctly handles range gaps, and the test coverage (TestRowMapping*) is thorough.

A few items below for your consideration.

Comment thread src/paimon/format/lance/lance_file_batch_reader.cpp
Comment thread src/paimon/format/parquet/parquet_file_batch_reader.h Outdated
Comment thread src/paimon/common/reader/prefetch_file_batch_reader_impl.cpp Outdated
Comment thread src/paimon/common/reader/prefetch_file_batch_reader_impl.cpp Outdated
zjw1111
zjw1111 previously approved these changes Jul 1, 2026

@zjw1111 zjw1111 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@zjw1111 zjw1111 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two minor non-blocking nits — feel free to address in a follow-up commit.

Comment thread include/paimon/reader/file_batch_reader.h Outdated
Comment thread src/paimon/common/reader/prefetch_file_batch_reader_impl.cpp Outdated
@zhf999
zhf999 requested a review from zjw1111 July 1, 2026 08:10
Comment thread src/paimon/testing/utils/read_result_collector.h
Comment thread src/paimon/testing/utils/read_result_collector.h
@zhf999
zhf999 requested a review from lxy-9602 July 1, 2026 08:36

@lxy-9602 lxy-9602 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

+1

@lxy-9602
lxy-9602 merged commit ee6159e into alibaba:main Jul 2, 2026
9 checks passed
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.

4 participants