Skip to content

feat(scanner): a logical-plan read path for plain scans - #8567

Draft
wjones127 wants to merge 1 commit into
will/logical-planner-3-execfrom
will/logical-planner-4-leaf
Draft

wjones127 wants to merge 1 commit into
will/logical-planner-3-execfrom
will/logical-planner-4-leaf

Conversation

@wjones127

@wjones127 wjones127 commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Scanner::create_plan builds DataFusion physical plans directly, by hand. This adds an alternative path that assembles the query as a LogicalPlan, runs a curated rule set over it, and lowers it with an ExtensionPlanner. It is off unless LANCE_LOGICAL_SCAN_PLANNER=1.

This first layer covers plain scans: filter, projection, sort, limit, aggregate. Searches and _rowoffset are rejected rather than silently mis-planned; later PRs add them.

The pieces are:

  • source — the scan leaf as a TableProvider, including the branch to the frozen legacy (v1) scan builder.
  • builder — Scanner state to an unoptimized LogicalPlan. Synchronous, no I/O.
  • context — the bridge. An OptimizerRule is synchronous and so cannot load index metadata; this fetches everything up front, and each rule holds an Arc to it.
  • scan_index — the one rule this layer has, recording on each scan leaf how it finds its rows, so the index decision is visible in the plan rather than private to TableProvider::scan.
  • planner — stage 4 dispatch, empty until a later layer adds a node.

ensure_supported destructures Scanner exhaustively, so a new field fails to compile until someone decides what this path does with it.

Every test in tests/ also plans the same query through the imperative path and asserts the two return the same rows in the same order. That comparison goes away with the imperative path; the assertions about the answer stay.


Stack created with GitHub Stacks CLI • Give Feedback 💬

`Scanner::create_plan` builds DataFusion physical plans directly, by hand.
This adds an alternative path that assembles the query as a `LogicalPlan`,
runs a curated rule set over it, and lowers it with an `ExtensionPlanner`.
It is off unless `LANCE_LOGICAL_SCAN_PLANNER=1`.

This first layer covers plain scans: filter, projection, sort, limit,
aggregate. Searches and `_rowoffset` are rejected rather than silently
mis-planned; later PRs add them.

The pieces are:

* `source` — the scan leaf as a `TableProvider`, including the branch to the
  frozen legacy (v1) scan builder.
* `builder` — `Scanner` state to an unoptimized `LogicalPlan`. Synchronous,
  no I/O.
* `context` — the bridge. An `OptimizerRule` is synchronous and so cannot
  load index metadata; this fetches everything up front, and each rule holds
  an `Arc` to it.
* `scan_index` — the one rule this layer has, recording on each scan leaf
  how it finds its rows, so the index decision is visible in the plan rather
  than private to `TableProvider::scan`.
* `planner` — stage 4 dispatch, empty until a later layer adds a node.

`ensure_supported` destructures `Scanner` exhaustively, so a new field fails
to compile until someone decides what this path does with it.

Every test in `tests/` also plans the same query through the imperative path
and asserts the two return the same rows in the same order. That comparison
goes away with the imperative path; the assertions about the answer stay.
@wjones127
wjones127 force-pushed the will/logical-planner-4-leaf branch from e1ddc5f to 13e8852 Compare August 17, 2026 19:08
@github-actions github-actions Bot added the Stale label Nov 16, 2026
@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot removed the Stale label Nov 17, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant