You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "tub (via GitHub)" <gi...@apache.org> on 2026/01/29 14:39:10 UTC
[I] [Feature] [python] Streaming Read Support in paimon-python [paimon]
tub opened a new issue, #7152:
URL: https://github.com/apache/paimon/issues/7152
### Search before asking
- [x] I searched in the [issues](https://github.com/apache/paimon/issues) and found nothing similar.
### Motivation
Currently, paimon-python only supports batch reads - users must manually poll for new snapshots and manage read progress themselves. This makes it difficult to build streaming data pipelines in Python that react to changes as they occur.
I'm proposing adding an asyncio-based streaming consumer, along with consumer-registration support. Wherever possible possible I've referred back to the Java implementation to keep them as similar as possible.
I have a PoC branch for this locally, but I want to get some buy-in on the idea first before I start polishing it and push it publicly :)
### Solution
### Architecture
```mermaid
flowchart TD
SRB[StreamReadBuilder<br/>with_poll_interval_ms<br/>with_consumer_id<br/>with_shard<br/>with_include_row_kind]
SRB --> ASTS[AsyncStreamingTableScan<br/>stream / stream_sync]
SRB --> TR[TableRead<br/>reused from batch]
SRB --> CM[ConsumerManager<br/>checkpoint / restore]
ASTS --> FUS[FollowUpScanner<br/>per-snapshot]
ASTS --> IDS[IncrementalDiffScanner<br/>catch-up mode]
```
### Key Classes
| Component | Purpose |
|-----------|---------|
| `StreamReadBuilder` | API for configuring streaming reads |
| `AsyncStreamingTableScan` | Core streaming engine with async iterator |
| `FollowUpScanner` | Interface for determining which snapshots to scan |
| `DeltaFollowUpScanner` | Scans APPEND commits (changelog-producer=none) |
| `ChangelogFollowUpScanner` | Scans changelog manifests (changelog-producer=input/full-compaction/lookup) |
| `IncrementalDiffScanner` | Efficient catch-up when many snapshots behind |
| `ConsumerManager` | Persists read progress for recovery |
## API Design
### Basic Usage
```python
table = catalog.get_table('database.table')
# Create streaming read builder
stream_builder = table.new_stream_read_builder()
stream_builder.with_poll_interval_ms(1000)
# Create scan and reader
scan = stream_builder.new_streaming_scan()
table_read = stream_builder.new_read()
# Async streaming (recommended)
async for plan in scan.stream():
arrow_table = table_read.to_arrow(plan.splits())
process(arrow_table)
# Or synchronous
for plan in scan.stream_sync():
arrow_table = table_read.to_arrow(plan.splits())
process(arrow_table)
```
### Consumer Registration (Progress Tracking)
Compatible with the Java implementation.
```python
stream_builder.with_consumer_id("my-etl-job")
async for plan in scan.stream():
process(table_read.to_arrow(plan.splits()))
# Persist progress to {table_path}/consumer/consumer-my-etl-job
scan.notify_checkpoint_complete(scan.next_snapshot_id)
```
### Parallel Consumption
Expose an API to allow building consumers with subsets of the buckets.
I'm not proposing we add any consumer group-membership synchronization in this, just the primitives that would allow folks to build that on top using an external strongly-consistent store like etcd/zookeeper.
```python
# Consumer 0 of 4 reads buckets 0, 4, 8, ...
stream_builder.with_shard(0, 4)
# Or explicit bucket list
stream_builder.with_buckets([0, 1, 2])
# Or custom filter
stream_builder.with_bucket_filter(lambda b: b % 2 == 0)
```
## Implementation Details
### Streaming Scan Flow
```mermaid
flowchart LR
IS[Initial Scan<br/>full state] --> POLL[Poll for New<br/>Snapshots]
POLL --> PLAN[Create Plan from<br/>Delta/Changelog]
POLL --> SHOULD{should_scan?}
SHOULD -->|APPEND| YES[Yes - scan]
SHOULD -->|COMPACT| NO[No - skip]
SHOULD -->|OVERWRITE| NO
```
### Changelog Producer Modes
| Mode | Scanner | Data Source |
|------|---------|-------------|
| `none` (default) | `DeltaFollowUpScanner` | `delta_manifest_list` |
| `input` | `ChangelogFollowUpScanner` | `changelog_manifest_list` |
| `full-compaction` | `ChangelogFollowUpScanner` | `changelog_manifest_list` |
| `lookup` | `ChangelogFollowUpScanner` | `changelog_manifest_list` |
### Performance Optimizations
These could potentially be added afterwards, but we've already seen these caches benefit us a lot on the Flink side when using S3:
1. **Snapshot Caching**: LRU cache for snapshot metadata
2. **Manifest Caching**: LRU cache for manifest file contents
3. **Batch Lookahead**: Fetch multiple snapshots in parallel to skip COMPACT commits efficiently
4. **Prefetching**: Background thread prefetches next snapshot while current is processed
5. **Diff-based Catch-up**: When >10ish snapshots behind, use `IncrementalDiffScanner` to compute file diff instead of reading N delta_manifest_lists
### Dependencies
- `cachetools` for LRU caching (already used by paimon-python)
- No additional dependencies required
### Anything else?
_No response_
### Are you willing to submit a PR?
- [x] I'm willing to submit a PR!
--
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: issues-unsubscribe@paimon.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Feature] [python] Streaming Read Support in paimon-python [paimon]
Posted by "tub (via GitHub)" <gi...@apache.org>.
tub commented on issue #7152:
URL: https://github.com/apache/paimon/issues/7152#issuecomment-4012110412
@JingsongLi @XiaoHongbo-Hope - I just realised that there's an inconsistency between the code and the docs.
In the docs we say that Python 3.10+ is required, but the codebase supports 3.6+.
Is there a reason to support anything below 3.10? 3.9 has been end-of-life since October last year, and 3.6 has been EOL since December 2021.
Supporting such old versions of python will severely hamper our security posture, and prevent us from pulling in bug-fixes and new features in our dependencies.
One example is `cachetools` - I was trying to remove a bunch of boilerplate code by using cachetools' decorators - but they're not available in a version that supports py3.6.
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Feature] [python] Streaming Read Support in paimon-python [paimon]
Posted by "tub (via GitHub)" <gi...@apache.org>.
tub commented on issue #7152:
URL: https://github.com/apache/paimon/issues/7152#issuecomment-3959392763
@XiaoHongbo-Hope @JingsongLi - You've both been pretty active in the python client recently - any comments on this proposal to add streaming read support?
I've got a working branch ready to push, but I'm holding off on some feedback on the overall approach before getting into the detail of the implementation.
Thanks!
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Feature] [python] Streaming Read Support in paimon-python [paimon]
Posted by "tub (via GitHub)" <gi...@apache.org>.
tub commented on issue #7152:
URL: https://github.com/apache/paimon/issues/7152#issuecomment-3998421252
My branch for this was getting quite unwieldy and hard to review, so I split it in three:
https://github.com/apache/paimon/pull/7342
https://github.com/apache/paimon/pull/7343
https://github.com/apache/paimon/pull/7344
The third is a pure python CLI - we don't necessarily have to package it up as part of the core library, but it's quite handy.
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Feature] [python] Streaming Read Support in paimon-python [paimon]
Posted by "XiaoHongbo-Hope (via GitHub)" <gi...@apache.org>.
XiaoHongbo-Hope commented on issue #7152:
URL: https://github.com/apache/paimon/issues/7152#issuecomment-4018319820
> [@JingsongLi](https://github.com/JingsongLi) [@XiaoHongbo-Hope](https://github.com/XiaoHongbo-Hope) - I just realised that there's an inconsistency between the code and the docs. In the docs we say that Python 3.10+ is required, but the codebase supports 3.6+.
>
> Is there a reason to support anything below 3.10? 3.9 has been end-of-life since October last year, and 3.6 has been EOL since December 2021.
>
> Supporting such old versions of python will severely hamper our security posture, and prevent us from pulling in bug-fixes and new features in our dependencies.
>
> One example is `cachetools` - I was trying to remove a bunch of boilerplate code by using cachetools' decorators - but they're not available in a version that supports py3.6.
Thanks for pointing out the issue, I thinka lot of users still use py36 in their production code.
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Feature] [python] Streaming Read Support in paimon-python [paimon]
Posted by "junmuz (via GitHub)" <gi...@apache.org>.
junmuz commented on issue #7152:
URL: https://github.com/apache/paimon/issues/7152#issuecomment-3835256131
This looks an interesting feature and would allow consuming data in a less expensive way for low throughput streams. Also, would be interesting to keep it compatible with Ray compute engine.
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Feature] [python] Streaming Read Support in paimon-python [paimon]
Posted by "tub (via GitHub)" <gi...@apache.org>.
tub commented on issue #7152:
URL: https://github.com/apache/paimon/issues/7152#issuecomment-3818102267
Also sorry for the wall of text! I tried to use diagrams where possible :)
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Feature] [python] Streaming Read Support in paimon-python [paimon]
Posted by "tub (via GitHub)" <gi...@apache.org>.
tub commented on issue #7152:
URL: https://github.com/apache/paimon/issues/7152#issuecomment-4040694727
Status update.
Merged Already:
https://github.com/apache/paimon/pull/7347 - Caching infrastructure + utilities
https://github.com/apache/paimon/pull/7348 - Scanners, sharding
https://github.com/apache/paimon/pull/7394 - Expose RowKind
Next:
https://github.com/apache/paimon/pull/7349 - Consumer registration and tracking
Coming up afterwards:
https://github.com/apache/paimon/pull/7350 - Add StreamReadBuilder and AsyncStreamingTableScan
At this point we are feature complete with streaming reads at the API level.
Then I'll rewrite https://github.com/apache/paimon/pull/7351 based on the new CLI tool in `master`.
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Feature] [python] Streaming Read Support in paimon-python [paimon]
Posted by "XiaoHongbo-Hope (via GitHub)" <gi...@apache.org>.
XiaoHongbo-Hope commented on issue #7152:
URL: https://github.com/apache/paimon/issues/7152#issuecomment-3998669898
> My branch for this was getting quite unwieldy and hard to review, so I split it in three:
>
> * [[python] Add streaming infrastructure: scanners, consumers, caching #7342](https://github.com/apache/paimon/pull/7342)
> * [[python] Add StreamReadBuilder and AsyncStreamingTableScan #7343](https://github.com/apache/paimon/pull/7343)
> * [[python] Add paimon tail CLI for streaming table reads #7344](https://github.com/apache/paimon/pull/7344)
>
> The third is a pure python CLI - we don't necessarily have to package it up as part of the core library, but it's quite handy.
Thanks! Will task a look at on it.
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org