Skip to content

feat(exec): exec-node changes the logical scan planner needs - #8566

Closed
wjones127 wants to merge 1 commit into
will/logical-planner-2-orderingfrom
will/logical-planner-3-exec
Closed

wjones127 wants to merge 1 commit into
will/logical-planner-2-orderingfrom
will/logical-planner-3-exec

Conversation

@wjones127

@wjones127 wjones127 commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Three independent changes to the read path's exec nodes, all of which the logical planner needs before it can build these nodes from rules:

  • SimplifyProjection folds a column-only projection into the projection below it and re-examines the result, so stacked projections collapse. A hand-built physical plan never emitted them; a lowered one does.
  • RowOffsetMap splits AddRowOffsetExec's fragment prefetch out of its constructor, so a planner that must build nodes synchronously can load it up front.
  • AddRowOffsetExec::partition_statistics now reports a column entry for the column it appends, instead of passing its input's statistics through unchanged.

Also fixes a capacity underflow in row_ids_for_mask: it subtracted the block list's length from the row count, which underflows when a plan materializes an index over a fragment subset the block list ranges beyond.


Stack created with GitHub Stacks CLI • Give Feedback 💬

Three independent changes to the read path's exec nodes, all of which the
logical planner needs before it can build these nodes from rules:

* `SimplifyProjection` folds a column-only projection into the projection
  below it and re-examines the result, so stacked projections collapse.
  A hand-built physical plan never emitted them; a lowered one does.
* `RowOffsetMap` splits `AddRowOffsetExec`'s fragment prefetch out of its
  constructor, so a planner that must build nodes synchronously can load it
  up front.
* `AddRowOffsetExec::partition_statistics` now reports a column entry for
  the column it appends, instead of passing its input's statistics through
  unchanged.

Also fixes a capacity underflow in `row_ids_for_mask`: it subtracted the
block list's length from the row count, which underflows when a plan
materializes an index over a fragment subset the block list ranges beyond.
@wjones127
wjones127 force-pushed the will/logical-planner-3-exec branch from c3a9ebc to acf0ad7 Compare August 17, 2026 19:08
LuQQiu pushed a commit that referenced this pull request Oct 15, 2026
ANN scans projecting `_rowoffset` with default distance ordering could
panic during physical optimization. `AddRowOffsetExec` appended an
output field but returned only the input columns’ statistics, causing
DataFusion’s projection statistics to index past the end.

Append unknown statistics for `_rowoffset` and clear the input-only byte
count while preserving the row count and existing column statistics.
This is a focused fix for the statistics issue also covered by #8566.

Regression coverage includes known and unknown statistics, global and
per-partition statistics, and three-fragment ANN queries with deletions,
stable and address-style row IDs, and both offset-only and
ID-plus-offset projections. ANN results assert exact neighbors, offsets,
distances, and recall of 1.0.

Validation on macOS arm64 with Rust 1.98.1 and the repository `ci`
profile:

- All 8 new regression cases fail on the unchanged base; ANN cases
reproduce the DataFusion projection panic.
- `cargo test --profile ci --locked -p lance --lib row_offset`: 11
passed.
- `cargo test --profile ci --locked -p lance --lib
io::exec::rowids::test`: 10 passed.
- `cargo clippy --profile ci --locked --all --tests --benches -- -D
warnings` passed.
- `cargo fmt --all -- --check` and `git diff --check` passed.
Xuanwo added a commit that referenced this pull request Nov 14, 2026
Closes #10854.

The value is only the initial capacity of the returned `Vec`, so it now
uses `saturating_sub`. The returned row ids are unchanged: the requested
fragments' row ids minus the blocked ones. Draft #8566 has the same
one-line change without a test, so whichever lands second can drop that
hunk.

## How was this patch tested

`test_not_equal_filter_on_fragment_subset_legacy_stable_row_ids` writes
100 rows in 10 fragments with legacy storage and stable row ids, builds
a BTree index, and scans fragment 0 with `c != 0`. It checks that the
plan uses `MaterializeIndex` and that the scan returns the fragment's 5
matching rows. Without this change it panics.

## Integration validation

Merged current `main` at `cdefd7edfc71f91368898d1fec6da789c5f80f5c` into
the PR branch; the diff against `main` remains the two files above
(+45/-2). On the merged tree:

- `cargo test -p lance --locked --profile ci
test_not_equal_filter_on_fragment_subset_legacy_stable_row_ids` — 1
passed.
- `cargo test -p lance --lib --locked --profile ci
io::exec::scalar_index::tests` — 13 passed.
- `cargo test -p lance --lib --locked --profile ci
test_btree_nullable_filters_match_unindexed_scan` — 1 passed.
- `cargo clippy --profile ci --all --tests --benches --locked -- -D
warnings` — clean.
- `cargo fmt --all` — clean.

The `Closes #10854` scope stays the legacy-storage, stable-row-id,
fragment-subset negated-index-filter panic described in the issue; the
saturating subtraction only protects the capacity hint, and row ids are
still filtered by `!block_list.contains`.

---------

Co-authored-by: Xuanwo <[email protected]>
@github-actions github-actions Bot added the Stale label Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution. This PR has been inactive for a while, so we're closing it to free up bandwidth. Feel free to reopen it if you still find it useful.

@github-actions github-actions Bot closed this Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant