GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — build: Cargo workspace + native-common extraction (1/6) by timsaucer · Pull Request #104 · apache/datafusion-java Conversation
|
|
@paleolimbot @coderfender Here is the first of six stacked PRs to add a spark data source that uses a datafusion table provider underneath. This one only moves things around in the repo to prepare for adding in the new crate. The full original PR #103 is way too large to review effectively so I've broken it into stages. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Refactors the Rust native build into a Cargo workspace and extracts shared JNI infrastructure into a new datafusion-jni-common crate, while updating Maven/scripts/CI to build from the workspace root and to use rust-target/ as the shared Cargo output directory.
Changes:
Cargo.toml and new native-common (datafusion-jni-common) crate; migrate shared JNI/runtime/streaming/error plumbing into it.rust-target/ via .cargo/config.toml and update Maven/Makefile/CI/release scripts to use workspace builds and the new artifact paths.Copilot reviewed 31 out of 33 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pom.xml | Pin maven-compiler-plugin version; update RAT/license excludes for rust-target/ and root Cargo.lock. |
| Cargo.toml | Add workspace root, members, shared package metadata, and centralized [workspace.dependencies]. |
| Cargo.lock | Move to workspace root; lockfile content updated for the new workspace resolution. |
| .cargo/config.toml | Set Cargo target-dir = "rust-target" to keep Rust artifacts out of Maven-cleaned target/. |
| .gitignore | Ignore rust-target/ in addition to target/. |
| Makefile | Build/format/clean via workspace root; update runtime-metrics build command to use -p datafusion-jni. |
| native/Cargo.toml | Convert to workspace-inherited metadata/deps; add dependency on datafusion-jni-common. |
| native/src/lib.rs | Remove local errors module + inline StreamingReader; use datafusion-jni-common errors/runtime/streaming. |
| native/src/arrow.rs | Switch JNI error handling imports to datafusion-jni-common. |
| native/src/avro.rs | Switch JNI error handling imports to datafusion-jni-common. |
| native/src/cache_manager.rs | Switch JniResult import to datafusion-jni-common. |
| native/src/csv.rs | Switch JNI error handling imports to datafusion-jni-common. |
| native/src/json.rs | Switch JNI error handling imports to datafusion-jni-common. |
| native/src/object_store.rs | Switch JniResult import to datafusion-jni-common. |
| native/src/proto.rs | Switch JNI error handling imports to datafusion-jni-common. |
| native/src/runtime_metrics.rs | Switch JniResult import and update rebuild instructions for workspace package selection. |
| native/src/schema.rs | Switch JniResult import to datafusion-jni-common. |
| native-common/Cargo.toml | Add new datafusion-jni-common crate definition + avro feature forwarding. |
| native-common/src/lib.rs | Add shared runtime singleton + StreamingReader implementation. |
| native-common/src/errors.rs | Add shared error-to-exception mapping + exported panic_message. |
| native-common/README.md | Document purpose/linking model/status of the new shared native crate. |
| core/pom.xml | Update expected native library path to rust-target/... and update failure guidance text. |
| core/src/main/java/org/apache/datafusion/SessionContext.java | Update user-facing build instructions for substrait/runtime-metrics to include -p datafusion-jni. |
| core/src/test/java/org/apache/datafusion/SessionContextRuntimeStatsTest.java | Update build instructions for runtime-metrics feature to include -p datafusion-jni. |
| core/src/test/java/org/apache/datafusion/SessionContextSubstraitTest.java | Update build instructions for substrait feature to include -p datafusion-jni. |
| .github/workflows/build.yml | Update cargo cache paths/keys for workspace root lockfile + rust-target/. |
| .github/workflows/lint.yml | Run formatting/clippy at workspace root; update cargo cache paths/keys. |
| docs/source/contributor-guide/development.md | Update dev instructions and describe new workspace + rust-target/ behavior. |
| docs/source/contributor-guide/updating-datafusion-version.md | Update version-bump procedure to reflect workspace dependency pinning. |
| dev/release/build-release.sh | Update native build/copy paths and build commands for workspace + rust-target/. |
| dev/release/datafusion-java-rm/build-native-libs.sh | Build datafusion-jni from repo root and reference rust-target/... outputs. |
| dev/release/rat_exclude_files.txt | Exclude root Cargo.lock instead of native/Cargo.lock. |
| dev/release/verify-release-candidate.sh | Run cargo fmt workspace-wide instead of only in native/. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I considered renaming |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Very cool! I'm happy to review this work because it's very relevant to what we do (Spark via Sedona Spark and DataFusion via SedonaDB), with the limitation that I don't have any experience with JNI (just general arrow-over-c). I do have a few questions about the approach before I get started. Notably, these are a few ways to avoid maintaining a pile of JNI (by exploiting other piles of JNI that other people have written already!) One approach is to use ADBC as the FFI bridge. As a TableProvider author, a thin layer of code (a few hundred lines) can get you a cdylib with the ADBC entrypoint defined, and on the Java side there is already a driver manager that can import the cdylib and "run a SQL query", getting one FFI_ArrowArrayStream per partition back. You have to figure out how to squeeze your scan options into the ADBC interface but you're already serializing/deserializing most of it. It might look like Another approach is to extract the FFI of the table provider you actually need and add it to At a high level I think my complaint about the approach in this stack is that you are proposing to build a cdylib that exports JNI entrypoints, whereas a cleaner approach (in my opinion) is to build a cdylib that exports entrypoints that just use the Arrow C Data/Stream interface and C types. That also has broader applicability to non-Java (i.e., can live in datafusion proper and get eyes/reviews from a wider audience). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @timsaucer
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I missed the conversation on here before merging. Sorry about that. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It’s my fault. I should have moved it to draft. I’ve been traveling and lost track |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
All good - we'll need dedicated Rust and Java components no matter how this goes. I am busy trying to get SedonaDB 0.4 out this week but can prototype the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@paleolimbot I started to churn on this and put up this PR: #110 I'm going to try digging in more tomorrow. I'll be out on vacation starting Thursday, so there's no rush on my side. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Introduce datafusion-scan-ffi: a cdylib exposing a DataFusion TableProvider scan through extern "C" entrypoints that speak only C primitives and the standard Arrow C Data/Stream interface (ArrowSchema/ArrowArrayStream). No JVM/JNI dependency, so the surface is consumable from Java (via a thin shim or FFM), Python, Go, or Rust, and is a candidate to live closer to DataFusion proper. This is the JNI-free reshaping of PR apache#103's scan logic per review feedback on PR apache#104: providers are compiled in and registered by name (approach A), filters cross as datafusion.LogicalExprNode protobufs (shared vocabulary with datafusion-ffi/Comet), and each scanned partition is handed back as a zero-copy FFI_ArrowArrayStream. - abi.rs: df_scan_{schema,create,partition_count,execute_partition, execute,close}, df_error_free, df_scan_abi_version - scan.rs: build -> register -> project -> filter -> plan core - registry.rs: name-keyed provider builders - reader.rs: SendableRecordBatchStream -> panic-safe RecordBatchReader - include/datafusion_scan.h: the C header - tests/roundtrip.rs: drives the ABI and re-imports the stream via the Arrow C Stream interface, no JVM involved (6 tests) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.