gengliangwang commented on PR #59520: URL: https://github.com/apache/spark/pull/59520#issuecomment-6867776559
Thanks, @szehon-ho. I agree that reviewing the individual lifecycles separately would help. My preference would be to keep this as one PR and organize the review in those stages. The existing native ABI already covers all four operations, and the SDK deliberately shares the reader factories across batch and streaming reads, and the task writers across batch and streaming writes. Reviewing the complete surface also helps check that those contracts remain consistent. Would reviewing the shared infrastructure and batch-read API first, then the remaining lifecycles within this PR, address the reviewability concern? **On the Arrow dependency:** Yes, the coupling at the Rust API is intentional. The Arrow C interface decouples the compiled connector from Spark's Arrow implementation; it does not make Rust types from different Arrow crate versions interchangeable inside the connector. Using concrete arrow-rs types lets connectors use its arrays and readers directly while the SDK handles the C boundary and ownership. A connector can depend on another Arrow major alongside the SDK, but values crossing the SDK's Rust API must use the SDK's version. Aligning the relevant dependencies and using the SDK's Arrow re-exports is the simplest integration path. When alignment is not possible, an explicit adapter is needed. The Arrow C Data/Stream interfaces are a possible bridge, subject to compatible types/layouts and correct ownership handling, but this PR does not provide an automatic cross-version adapter. An Arrow-major upgrade is therefore a breaking SDK release, independently of Spark's C ABI compatibility. **On the read API structure:** The driver/executor separation makes the serialization and resource-ownership boundary explicit: planning stays on the driver, only the factory and partition descriptors travel to executors, and each task attempt opens its own live reader. The Java `ScanBuilder -> Scan -> Batch` layers still exist in Spark's JVM adapter. The Rust `plan(self)` corresponds to partition planning, rather than Java's `ScanBuilder.build()`. [`ColumnarBatchScan`](https://github.com/apache/spark/blob/04f6e3eb5f91e662d0ee8ec05e2f1223dddb70bc/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/columnar/ColumnarTable.scala#L270) obtains and caches the partitions and factory together, and [`NativeBatchPlanner`](https://github.com/apache/spark/blob/04f6e3eb5f91e662d0ee8ec05e2f1223dddb70bc/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/ffi/NativeDataSource.scala#L313) closes the native planner handle after planning. Consuming the Rust builder expresses that existing lifecycle. It is a design choice aligned with the current native contract, not an inherent limitation of C or FFM. Statistics, partitioning/ordering reports, and runtime filtering are not currently exposed by the native path. Supporting them would require corresponding JVM and ABI hooks at the appropriate planning stages. Statistics may be needed before partition planning, so adding fields to the final `ScanPlan` alone would not address that requirement; a separate Rust scan abstraction may make sense when those stages are exposed. Runtime replanning would also need retained or reconstructible scan state and defined snapshot and plan-cache semantics. Changing `plan(self)` to `plan(&mut self)` alone would not enable it, because the current host closes the handle and caches the plan. That extension may require a different Rust scan lifecycle and a breaking SDK release. The experimental 0.x API does not promise that every future DSv2 capability can be added without such changes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
