- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2026 11:54 AM
Hi everyone,
I’m working on a use case where I need to retain 30 days of historical data in a Delta table and use it to build trend reports.
I’m looking for the best approach to reliably maintain this historical data while also making it suitable for reporting. I explored the Delta Lake time travel feature, but it currently only allows access to about 7 days of history, which doesn’t meet my requirement.
What would be the recommended way to handle this scenario?
Thank you!
- Labels:
-
Delta Lake
-
Spark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2026 01:20 PM - edited 04-20-2026 01:23 PM
Hi @Raj_DB ,
For reliable 30-day trend reporting, don't rely on time travel — use an explicit snapshot table instead.
The pattern:
1. Daily job appends a snapshot of your source table to a history table with a snapshot_date partition column
2. Purge rows older than 30 days with a scheduled DELETE WHERE snapshot_date < current_date() - INTERVAL 30 DAYS
3. Run VACUUM after to reclaim storage.
This gives you full control over retention and keeps trend queries fast via partition pruning.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2026 01:24 AM
Thanks @lingareddy_Alva for your suggestion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2026 01:47 PM
You’re hitting the new 7-day time-travel enforcement: in recent runtimes, time travel is blocked beyond delta.deletedFileRetentionDuration (default 7 days), regardless of VACUUM args or logRetentionDuration.
To support 30 days of historical data for reporting, you have two options:
1. Use Delta retention settings for 30-day time travel
If 30 days is enough history and you’re okay paying for the extra storage, just configure the table’s Delta properties:
ALTER TABLE catalog.schema.table_name
SET TBLPROPERTIES (
'delta.deletedFileRetentionDuration' = 'interval 30 days',
'delta.logRetentionDuration' = 'interval 30 days'
);
delta.deletedFileRetentionDurationcontrols how long old data files are kept and therefore the maximum time-travel window (default 7 days).delta.logRetentionDurationcontrols how long the transaction log/history is kept (default 30 days) and must be ≥deletedFileRetentionDurationin new runtimes.- Docs explicitly note: to access 30 days of history, set
delta.deletedFileRetentionDuration = "interval 30 days"to match the defaultlogRetentionDuration.
This is the simplest way to have a 30-day rolling history directly available via time travel for your trend reports.
2. (Recommended for robust reporting) Build a dedicated history / trend table
Delta docs and guidance caution against relying on table history as a long-term backup or analytics store and recommend using history/time travel mainly for short-term ops and recovery.
For reporting use cases (especially if you may want >30 days later), a common pattern is:
- Create a separate “history” or “snapshot” Delta table, partitioned by a logical date (e.g.,
snapshot_dateor business date). - On a daily job (or whatever cadence you need):
- Either:
- Take a point-in-time snapshot of the source table and append it with that day’s
snapshot_date, or - Use Change Data Feed (CDF) to upsert incremental changes into a slowly-changing dimension / fact table with effective dates.
- Take a point-in-time snapshot of the source table and append it with that day’s
- Either:
- Point your BI / trend reports at this reporting table, not at time-travel queries.
This pattern keeps reporting predictable and decoupled from operational retention and VACUUM settings, while you still keep ~30 days of native time travel for debugging and recovery.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2026 05:20 AM
Hi @DivyaandData , Thank you so much for the explanation. I have one question: why is time travel not a good choice, and does it cost more than using a simple append-only history table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2026 10:41 AM
Hello,
TT s useful for operational recovery, debugging and short term rollback, but it’s usually not the best for reporting.Why ? because simply reporting needs a stable and historical model. TT gives you old table versions but it does not give you a business friendly history structure such as snapshot dates, effective dates, change types or even premodeled trends. It is also coupled to retention settings and file lifecycle behavior, including VACUUM and for UC MT and PO which runs VACUUM automatically.
Senior BI/Data Engineer | Microsoft MVP Data Platform | Microsoft MVP Power BI | Power BI Super User | C# Corner MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2026 08:18 AM
Hey @Raj_DB , The TLDR is time travel is great for short-term ops and debugging, but brittle as your primary reporting history, and its cost profile is harder to control and reason about than a purpose-built history table.
- Docs 1,2 explicitly say Delta table history/time travel is for auditing, rollback, and point-in-time queries, and is not recommended as a long-term backup/archival solution.
- In new runtimes, time travel is blocked once you go beyond
delta.deletedFileRetentionDuration(default 7 days), regardless of VACUUM arguments. Source
- There’s no separate “time travel fee” – you pay for storage and compute in both patterns. The cost difference comes from how much data you retain and how it’s organized.
- To get a long time-travel window, you must keep all old data files and logs for the source table for that period (
deletedFileRetentionDurationandlogRetentionDuration), which increases storage and can slow queries because they scan more versions/files. Source
With a dedicated history table, you can:
- Store only what reporting needs (e.g., daily snapshots or SCD facts instead of every tiny intermediate write).
- Partition and compact for reporting patterns.
- Apply your own retention (e.g., 13 months) without affecting operational tables or being surprised by VACUUM behavior.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2026 01:26 AM
Thank you, @DivyaandData , for the clear and detailed explanation - I really appreciate it.