You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "Yohahaha (via GitHub)" <gi...@apache.org> on 2026/10/21 08:50:50 UTC
[I] [spark] Support table snapshots at a Fluss commit timestamp [fluss]
Yohahaha opened a new issue, #4776:
URL: https://github.com/apache/fluss/issues/4776
### Search before asking
- [x] I searched the issues and found no existing issue specifically tracking a Spark commit-time snapshot TVF backed by a historical Paimon base and bounded Fluss replay.
### Motivation
Daily reconciliation and reporting need the complete state of a Fluss table at a specific boundary, for example midnight on a past day. The boundary should use Fluss commit time, not event time or the Paimon snapshot creation time.
A Fluss-only scan may be incomplete because older data has been tiered to Paimon. Conversely, Paimon snapshots do not necessarily align with midnight. For primary-key tables, reading only the retained changelog also loses unchanged keys and cannot reconstruct the complete state. Log tables must preserve duplicate rows.
We need a Spark SQL entry point that restores a complete state when the required history is available, without scheduling a dedicated daily snapshot or waiting for tiering to produce a snapshot exactly at the requested time.
### Solution
Add a batch TVF:
```sql
SELECT *
FROM fluss_snapshot_at_timestamp('fluss_catalog.db.orders', DATE '2026-10-20');
SELECT *
FROM fluss_snapshot_at_timestamp('fluss_catalog.db.orders', now());
```
- Restore changes whose Fluss commit timestamp is strictly less than the requested time; exclude records exactly at the boundary.
- Accept `now()` and `current_timestamp()`, resolve the time once, and reject future timestamps.
- Select a complete retained Paimon base by its per-bucket Fluss offsets, then replay the complete bounded Fluss log interval to the target boundary.
- Reuse existing Spark lake readers and primary-key merge logic. Apply filters and limits to the restored state.
- Fail explicitly when history is insufficient. If a candidate references a missing `fluss-offsets` file, report the table, snapshot ID and path rather than falling back to an older candidate.
Initial scope: Spark batch, non-partitioned tables with stable schema and bucket mappings, Paimon maintained exclusively by Fluss tiering, and deduplicate primary-key tables without KV TTL. Support both primary-key and log tables; no Flink feature is proposed.
### Anything else?
Paimon snapshot retention alone is insufficient: the referenced `fluss-offsets` file and required Fluss log interval must also be retained. Ordinary non-DV tiering currently removes previous offset files when registering a newer base. This proposal does not change that lifecycle or add offset archival, so it does not guarantee arbitrary historical dates under the default retention behavior.
DV bases are eligible only when their complete offsets are available and no L0 files remain. Historical DDL, external writes and overwrite/truncate recovery are outside the initial scope.
### Willingness to contribute
- [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@fluss.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org