Title: feat(substrait): add SessionContext.fromSubstrait gated behind opt-in Cargo feature by LantaoJin · Pull Request #80 · apache/datafusion-java · GitHub
Open Graph Title: feat(substrait): add SessionContext.fromSubstrait gated behind opt-in Cargo feature by LantaoJin · Pull Request #80 · apache/datafusion-java
X Title: feat(substrait): add SessionContext.fromSubstrait gated behind opt-in Cargo feature by LantaoJin · Pull Request #80 · apache/datafusion-java
Description: Which issue does this PR close? Closes #75 . Rationale for this change SessionContext.fromProto(byte[]) accepts only DataFusion's own LogicalPlanNode proto. Substrait — the cross-engine logical-plan standard that DataFusion already supports through the datafusion-substrait crate — has had no Java-side entry point. Embedders that compile plans elsewhere (Calcite via Isthmus, custom planners, federation hubs, integrations with other engines) had to round-trip through SQL to use the Java binding. That round-trip is lossy: source-side optimisations baked into the Substrait plan are discarded, and SQL is not always expressive enough to round-trip cleanly when plans reference extensions or function variants with no surface SQL form. What changes are included in this PR? This PR adds a single new entry point that mirrors the existing fromProto shape but consumes Substrait Plan bytes instead. The implementation is small (~50 LOC of JNI plus ~25 LOC on the Java side); the bulk of the diff is the test that round-trips a hand-built Substrait plan through the JNI bridge. New public Java API on SessionContext: public DataFrame fromSubstrait(byte[] planBytes); planBytes is a serialised substrait.proto.Plan. The plan is translated against this context's catalog: any tables it references must already be registered. The returned DataFrame is lazy and composes with the rest of the API. Default-off, so cargo build (and therefore make test, make, and everyone who doesn't need Substrait) stays hermetic without any new build prerequisites. Substrait support is opt-in: invocation substrait support build prereqs cargo build (default) off (stub handler) none cargo build --features substrait on protoc on PATH cargo build --features substrait,protoc on (vendored protoc) cmake on PATH The Java surface is unchanged either way — SessionContext.fromSubstrait(...) is always present; calls just throw a clear "datafusion-jni was built without the substrait Cargo feature; rebuild with --features substrait" error from the JVM if the feature was compiled off. SessionContextSubstraitTest detects this case and skips itself via JUnit's Assumptions.assumeFalse(...), so make test stays green either way. This is intentionally different from PR #60's avro handling, which is always-on. Are these changes tested? Yes, 7 new tests in SessionContextSubstraitTest Are there any user-facing changes? Yes, purely additive. New public API: SessionContext.fromSubstrait(byte[]) → DataFrame No API removals, no deprecations, no behavior change for existing callers. The default cargo build does not pull in datafusion-substrait and adds no new build prerequisites; SessionContext.fromSubstrait(...) is present but throws "feature not enabled" at runtime. Users who need Substrait rebuild with --features substrait (and either install protoc or also enable the protoc helper feature). The native binary is unchanged in size unless the feature is opted in. The new test-scope dependency io.substrait:core:0.81.0 is added to the parent POM's dependencyManagement (with version property substrait.java.version) and to core/pom.xml in test scope only; it does not enter the runtime classpath of the published artifact.
Open Graph Description: Which issue does this PR close? Closes #75 . Rationale for this change SessionContext.fromProto(byte[]) accepts only DataFusion's own LogicalPlanNode proto. Substrait — the cross-engine logic...
X Description: Which issue does this PR close? Closes #75 . Rationale for this change SessionContext.fromProto(byte[]) accepts only DataFusion's own LogicalPlanNode proto. Substrait — the cross-engine l...
Opengraph URL: https://github.com/apache/datafusion-java/pull/80
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:58e32bb2-9904-8201-9e10-c54bb87343c3 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D382:2D5850:3F4A61:58C5DD:6B046F2D |
| html-safe-nonce | 0dee115c4308bf0aa3ec122669d59b5accb15b84c083dc640d58fd7aa93cd1a9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzgyOjJENTg1MDozRjRBNjE6NThDNUREOjZCMDQ2RjJEIiwidmlzaXRvcl9pZCI6IjQ0NDk4ODM5OTc5MDgyNjY3OTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 983c0c95f1cb435cfdfb28e33790766378b3424ee0d5ab882f4e76b55fe594b3 |
| hovercard-subject-tag | pull_request:3721396620 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/apache/datafusion-java/pull/80/files |
| twitter:image | https://avatars.githubusercontent.com/u/1853780?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1853780?s=400&v=4 |
| og:image:alt | Which issue does this PR close? Closes #75 . Rationale for this change SessionContext.fromProto(byte[]) accepts only DataFusion's own LogicalPlanNode proto. Substrait — the cross-engine logic... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | ae8802492f12d3ba4f6b0d814054e617a2a5616b6327bf8555c10cd5b0dc2a6f |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/apache/datafusion-java git https://github.com/apache/datafusion-java.git |
| octolytics-dimension-user_id | 47359 |
| octolytics-dimension-user_login | apache |
| octolytics-dimension-repository_id | 1237105117 |
| octolytics-dimension-repository_nwo | apache/datafusion-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1237105117 |
| octolytics-dimension-repository_network_root_nwo | apache/datafusion-java |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cfb5f24c6e01d85f70804652a5107e5cac03a161 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width