Expose native Lance scan descriptor for datafusion-comet integration#624
Draft
wirybeaver wants to merge 2 commits into
Draft
Expose native Lance scan descriptor for datafusion-comet integration#624wirybeaver wants to merge 2 commits into
wirybeaver wants to merge 2 commits into
Conversation
Contributor
|
ACTION NEEDED The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification. For details on the error please inspect the "PR Title Check" action. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #623.
Summary
This adds a stable native-read descriptor for ordinary Lance Spark scans so native engines can consume Spark-planned Lance reads without depending on Lance Spark internals.
The descriptor captures:
The v1 scope is ordinary table reads only. Search/hybrid search, index-backed execution descriptors, aggregation pushdown, metadata/version columns, and namespace-backed credential refresh remain fallback/future work.
Why LanceScan carries the descriptor state
This PR adds several parameters to the
LanceScanconstructor becauseLanceScanis the object Spark keeps insideBatchScanExecafter planning. A native consumer such as Comet sees that finalBatchScanExec(scan = LanceScan)object, not the earlierLanceScanBuilderor catalog planning context. ThereforenativeScanPlan()needs the complete, already-resolved scan snapshot onLanceScanitself.The goal is not to make the constructor a broad public API. The goal is to avoid asking native consumers to infer or recompute Lance Spark planning semantics from partial state. Re-planning later would be risky because it could reopen a different dataset version, use different storage options, produce different fragments, or miss fallback-only state such as pushed TopN/aggregation.
The added state is the minimum needed to describe or reject the native v1 scan accurately:
sparkReadSchemaandschemakeep the Spark-visible schema and projected read schema separate, which matters when Spark-facing fields differ from the physical/projection schema.readOptionsprovides dataset URI, resolved version, batch size, table/catalog identifiers, and user storage options. The resolved version is required so native execution cannot drift to a newer Lance snapshot.whereConditions,limit, andoffsetare serialized into the descriptor when v1 supports them.topNSortOrdersandpushedAggregationare carried even though v1 falls back for them, because the descriptor must reject those scans explicitly instead of silently dropping semantics.pushedPredicates, zonemap stats, surviving fragment IDs, precomputed splits, and fragment row counts preserve the fragment-pruning and limit-pruning decisions Lance Spark already made on the driver.activeShardingExpressionandfragmentShardingKeyspreserve the existing partitioning/reporting contract used by Lance Spark planning.initialStorageOptions,namespaceImpl, andnamespacePropertiespreserve storage option precedence and the namespace context that workers/native readers need for the same dataset access path.A follow-up cleanup could wrap this constructor state into an internal immutable scan-state object if reviewers prefer that shape. This PR keeps the change direct so the descriptor contract and tests are easy to review first.
Testing
./mvnw -pl lance-spark-base_2.12 -Dtest=LanceScanTest -Dspotless.skip=true test./mvnw -pl lance-spark-4.1_2.13 -am -Dtest=LanceScanTest -Dspotless.skip=true -Dsurefire.failIfNoSpecifiedTests=false test./mvnw -pl lance-spark-base_2.12 spotless:check