Apache Gluten write support in lance-spark #709
Replies: 3 comments
|
Thanks for the well-scoped proposal — I read it against the current write path on Q1 — factory shape. Q2 — return type. Return the opaque Two small things for the implementation PR:
Splitting delivery across the two repos (factory + tests here, columnar writer + fallback in gluten) makes sense. cc @hamersaw for the API-shape call. |
|
Doing a quick scan over this, I don't have any concerns. It sounds like @LuciferYang has been iterating on the discussion gluten-side for a bit (thanks!). I'm excited to review the PR. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
This discussion proposes one small public API in
lance-sparkto support Apache Gluten's columnar write path: a factory that wraps executor-produced LanceFragmentMetadatain the commit-message type expected byLanceBatchWrite.The intended write flow was discussed in Apache Gluten issue #12263 and narrowed in the maintainer write-path analysis:
WriterCommitMessage.LanceBatchWrite.commit(...)performs the driver-side Lance transaction.Steps 1 and 2 do not require a
lance-sparkchange. Step 4 already exists. The proposed factory supplies the missing bridge in step 3.I am opening a Discussion before a PR because this adds a public API, following the
lance-sparkcontribution guidelines.Current limitation
LanceDataWritercurrently creates the expected commit message internally:LanceBatchWrite.commit(...)later consumes those messages and commits their fragments. However, theTaskCommitconstructor is package-private, so a columnar writer outsideorg.lance.spark.writecannot create a compatible message from itsList<FragmentMetadata>.The driver-side commit should remain in
LanceBatchWrite. Reusing it avoids duplicating append and overwrite operations, transaction construction, optimistic-concurrency handling, namespace integration, storage options, stable-row-ID handling, and staged-commit behavior in Gluten.Proposed API
Add a public static factory on
LanceBatchWrite:Example use from an external columnar writer:
Returning
WriterCommitMessagekeepsTaskCommitand its fragment accessor as implementation details. The caller only needs to create the message and return it through Spark's existing writer-commit protocol;LanceBatchWriteremains responsible for reading and committing it.If maintainers prefer callers to depend on the concrete type, the factory could instead return
TaskCommit. We do not currently see a need to make the constructor orgetFragments()public.Scope
This proposal changes only
lance-spark. It does not change fragment-writing behavior or introduce another writer implementation.The initial Gluten integration is expected to enable the columnar path only for existing-table batch writes where it can preserve the behavior of the current Lance writer. Its first scope is:
Gluten will fall back to the existing Lance Spark row writer when those conditions are not met. These restrictions belong to the Gluten integration and do not need to be encoded in the commit-message factory.
This proposal does not include:
LanceSchema;SparkWrite.getWriteOptions()public;TaskCommit;As confirmed in the Gluten follow-up,
WriteFragmentBuilder.schema(...)may later avoid an executor-side dataset open, but it is an optional performance optimization and is not required for this writer to be correct.Compatibility and ownership
The factory is additive. Existing
LanceDataWriterbehavior and theBatchWritecontract do not change.The ownership boundary remains the same as the current writer:
LanceBatchWriteowns the transaction and final commit.The API does not expose Arrow Java vectors across the Gluten/lance-spark boundary. Fragment data continues to cross through the Arrow C interface used by the existing Lance API.
Testing
The implementation PR should include focused tests that verify:
org.lance.spark.writecan create a commit message through the factory;LanceBatchWrite.commit(...);LanceDataWritercommit behavior remains unchanged.The Gluten-side integration will separately test its supported write modes and deterministic fallback for unsupported tables.
Delivery
After agreement, this can be delivered independently in two repositories:
lance-spark: add the public factory and focused tests.gluten: add the columnar Lance writer and its validation/fallback rules.The
lance-sparkchange does not depend on the read-path work or on a new Lance Java API.Questions for maintainers
LanceBatchWrite.taskCommit(List<FragmentMetadata>)the preferred public factory shape?WriterCommitMessage, or should it returnTaskCommit?All reactions