feat(table): expose `registerStreamingTable` for push-mode batch ingest
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 38/100
Research direction
Start with the existing SessionContext.registerTable/TableProvider path from PR #65 and the prior-art entry point rust/src/api.rs:572, register_partition_stream. Trace the Data.exportVectorSchemaRoot and StreamingTable/PartitionStream integration described in the issue; done means producers can write, close, or fail concurrently with query reads, with backpressure, cancellation, error propagation, and single-scan semantics documented and enforced.
Written by the indexing model from the issue text.
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 reads the returned ArrowReader.
But it does not cover the push shape that event-driven batch sources need:
- A coordinator that reduces over shard responses arriving incrementally -- the producer can't materialise an
ArrowReaderbecause the next batch hasn't arrived yet. - A Flight stream feeding into a query -- same problem; the producer is event-driven.
- Any in-process producer that emits batches as side-effects of other work and doesn't know in advance how many will arrive.
To 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.
DataFusion itself solves this on the Rust side with StreamingTable + PartitionStream plus an mpsc channel: producer pushes Result<RecordBatch> 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.
Describe the solution you'd like
One new method on SessionContext returning a TableSink:
TableSink sink = ctx.registerStreamingTable("shard_results", schema, capacity);
// Producer thread (any thread, including outside any Tokio runtime):
try {
while (hasMoreInput()) {
sink.write(batch); // backpressures when channel is full
}
sink.close(); // EOF: queries see end-of-stream cleanly
} catch (Throwable t) {
sink.fail(t); // signal error: queries see RuntimeException
}
public final class TableSink implements AutoCloseable {
void write(VectorSchemaRoot batch); // exports via Data.exportVectorSchemaRoot
void close(); // EOF
void fail(Throwable cause); // error propagated to readers
}
After registration the table can be referenced like any other registered table:
DataFrame df = ctx.sql("SELECT count(*) FROM shard_results");
ArrowReader r = df.executeStream(allocator);
// Producer thread continues writing as r.loadNextBatch() drains.
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.
This 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.
Describe alternatives you've considered
BlockingArrowReaderadapter on top of PR #65'sregisterTable. 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-canonicalStreamingTableshape is strictly less code and gets cancellation propagation for free.- Backpressure-free
try_write. A non-blocking variant that returnsfalsewhen the channel is full. Easy to add later as a follow-up if anyone wants it; not in scope here. Defaultwriteblocks, which is the contract every Java I/O caller expects. - Reuse PR #65's
TableProviderinterface and wrap mpsc internally. Considered. The problem: PR #65'sscan(BufferAllocator) -> ArrowReaderreturns synchronously, so a mpsc-backed implementation has to block onloadNextBatch()waiting for the producer -- exactly the serialisation point we're trying to avoid. Going direct toStreamingTable+PartitionStreamis the right layer.
Additional context
- The OpenSearch backend's
rust/src/api.rs:572register_partition_streamis 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.
- Dominant language
- Java
- Stars
- 32
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/datafusion-java
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
apache/datafusion-java#116 ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
apache/datafusion-java#112 ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 42/100
apache/datafusion-java#96 ·
-
Create first release Openenhancement
Difficulty 4/5 3-5 days Newbie friendliness 35/100
apache/datafusion-java#86 · 3 comments ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 45/100
apache/datafusion-java#68 ·
All issues in apache/datafusion-java
Similar issues
-
bug untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
opensearch-project/ml-commons#5094 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
emitter:client:csharp feature
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
affects/8.10 affects/8.9 component/clients kind/bug likelihood/mid severity/mid
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Two open-case totals on one screen: the Programs tile says 15,858 and the nav badge says 15,868 Openbug frontend maui-pilot
Difficulty 2/5 1-3 hours Newbie friendliness 72/100