Title: feat(table): expose `registerStreamingTable` for push-mode batch ingest · Issue #95 · apache/datafusion-java · GitHub
Open Graph Title: feat(table): expose `registerStreamingTable` for push-mode batch ingest · Issue #95 · apache/datafusion-java
X Title: feat(table): expose `registerStreamingTable` for push-mode batch ingest · Issue #95 · apache/datafusion-java
Description: Is your feature request related to a problem or challenge? PR #65 shipped a Java-implemented TableProvider and SessionContext.registerTable(String, TableProvider). That covered the pull shape: DataFusion calls scan(BufferAllocator) and r...
Open Graph Description: Is your feature request related to a problem or challenge? PR #65 shipped a Java-implemented TableProvider and SessionContext.registerTable(String, TableProvider). That covered the pull shape: Data...
X Description: Is your feature request related to a problem or challenge? PR #65 shipped a Java-implemented TableProvider and SessionContext.registerTable(String, TableProvider). That covered the pull shape: Data...
Opengraph URL: https://github.com/apache/datafusion-java/issues/95
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat(table): expose `registerStreamingTable` for push-mode batch ingest","articleBody":"### Is your feature request related to a problem or challenge?\n\nPR **#65** shipped a Java-implemented `TableProvider` and `SessionContext.registerTable(String, TableProvider)`. That covered the **pull** shape: DataFusion calls `scan(BufferAllocator)` and reads the returned `ArrowReader`.\n\nBut it does **not** cover the **push** shape that event-driven batch sources need:\n\n- A coordinator that reduces over shard responses arriving incrementally -- the producer can't materialise an `ArrowReader` because the next batch hasn't arrived yet.\n- A Flight stream feeding into a query -- same problem; the producer is event-driven.\n- Any in-process producer that emits batches as side-effects of other work and doesn't know in advance how many will arrive.\n\nTo bridge these into PR #65 today, callers have to write a `BlockingArrowReader` adapter that buffers pushed batches and serves them through the pull interface. That's a serialisation point: the producer blocks waiting for `loadNextBatch()` to be called, or DataFusion blocks waiting for the next batch -- the two ends can never run truly concurrently. The adapter also has to invent its own backpressure semantics, error propagation, end-of-stream signalling, and thread-safety story.\n\nDataFusion itself solves this on the Rust side with `StreamingTable` + `PartitionStream` plus an mpsc channel: producer pushes `Result\u003cRecordBatch>` into the sender, the consumer (DataFusion's `StreamingTableExec`) polls the receiver as part of normal query execution. The two ends decouple via the channel buffer, with the runtime providing backpressure and cancellation propagation.\n\n### Describe the solution you'd like\n\nOne new method on `SessionContext` returning a `TableSink`:\n\n```java\nTableSink sink = ctx.registerStreamingTable(\"shard_results\", schema, capacity);\n// Producer thread (any thread, including outside any Tokio runtime):\ntry {\n while (hasMoreInput()) {\n sink.write(batch); // backpressures when channel is full\n }\n sink.close(); // EOF: queries see end-of-stream cleanly\n} catch (Throwable t) {\n sink.fail(t); // signal error: queries see RuntimeException\n}\n```\n\n```java\npublic final class TableSink implements AutoCloseable {\n void write(VectorSchemaRoot batch); // exports via Data.exportVectorSchemaRoot\n void close(); // EOF\n void fail(Throwable cause); // error propagated to readers\n}\n```\n\nAfter registration the table can be referenced like any other registered table:\n\n```java\nDataFrame df = ctx.sql(\"SELECT count(*) FROM shard_results\");\nArrowReader r = df.executeStream(allocator);\n// Producer thread continues writing as r.loadNextBatch() drains.\n```\n\n**Single-scan semantics.** The registered table can only be queried *once*. After that scan completes (or is cancelled), the sink is no longer usable and the table cannot be re-scanned. This is the natural semantic for an event-driven producer -- the data is consumed as it arrives -- and matches what every downstream Substrait/Calcite plan that uses streaming tables already assumes. Documented loudly on `registerStreamingTable`'s Javadoc; trying to re-execute against the same registration throws.\nThis is intentional. Re-scannable streaming would require buffering every batch internally, which defeats the streaming use case. Callers who need to re-scan the same data should use the existing `registerTable` / `SimpleTableProvider` pull shape (PR #65) instead.\n\n\n\n### Describe alternatives you've considered\n\n- **`BlockingArrowReader` adapter on top of PR #65's `registerTable`.** What every caller currently has to hand-roll. It works but pushes the channel + backpressure + EOF + error story onto every embedder. Bridging via the upstream-canonical `StreamingTable` shape is strictly less code and gets cancellation propagation for free.\n- **Backpressure-free `try_write`.** A non-blocking variant that returns `false` when the channel is full. Easy to add later as a follow-up if anyone wants it; not in scope here. Default `write` blocks, which is the contract every Java I/O caller expects.\n- **Reuse PR #65's `TableProvider` interface and wrap mpsc internally.** Considered. The problem: PR #65's `scan(BufferAllocator) -> ArrowReader` returns synchronously, so a mpsc-backed implementation has to block on `loadNextBatch()` waiting for the producer -- exactly the serialisation point we're trying to avoid. Going direct to `StreamingTable` + `PartitionStream` is the right layer.\n\n### Additional context\n\n- The OpenSearch backend's `rust/src/api.rs:572` `register_partition_stream` is the prior-art template; it does almost exactly this. The Java side there uses a hand-rolled FFM bridge (`sender_send`) that can be replaced with this surface as soon as it lands.","author":{"url":"https://github.com/LantaoJin","@type":"Person","name":"LantaoJin"},"datePublished":"2026-05-26T07:39:31Z","url":"https://github.com/apache/datafusion-java/issues/95"}
| 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 | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9e98ce1c-59f9-147c-40f1-9398aee0b8b0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C400:29272F:232139:307B9A:6B0467EE |
| html-safe-nonce | 52af8cee41ae8fb2ba8f4238f4601465428e3962aafd9c21081ed04ea0ea30a6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNDAwOjI5MjcyRjoyMzIxMzk6MzA3QjlBOjZCMDQ2N0VFIiwidmlzaXRvcl9pZCI6IjQ3NTU5Njk5MTQ2MTQwODE1MTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | db87ce79c0690efdad046460d36773b1a7a7c9fc5cbad64243916e8d3e4f4614 |
| hovercard-subject-tag | issue:4522366382 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/apache/datafusion-java/95/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b56197f8ee2c491e41fdcf4073f3affd5aa0d6c9010b7c2897cdb48e21a8272c/apache/datafusion-java/issues/95 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b56197f8ee2c491e41fdcf4073f3affd5aa0d6c9010b7c2897cdb48e21a8272c/apache/datafusion-java/issues/95 |
| og:image:alt | Is your feature request related to a problem or challenge? PR #65 shipped a Java-implemented TableProvider and SessionContext.registerTable(String, TableProvider). That covered the pull shape: Data... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LantaoJin |
| hostname | github.com |
| expected-hostname | github.com |
| None | 83e4c0e58c5162177f3c161c5fbad38527ae04c11ac14980f9f9d85ae2027b1f |
| turbo-cache-control | no-preview |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ca4d07a7cef4e4b75f821dc25e7300d80c1450a9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width