<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Table history time travel in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/table-history-time-travel/m-p/159150#M54793</link>
    <description>&lt;P class=""&gt;&lt;SPAN&gt;I have noticed what seems to be unexpected behavior with the history of Unity Catalog managed tables and would like to understand whether this is expected.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;As a test, I created a table with two versions:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Version 0&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Version 1 (created approximately 200 hours ago)&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;&lt;SPAN&gt;Version 1 is still the current version of the table. At this point, the following query works as expected:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;SELECT * FROM table VERSION AS OF 1;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P class=""&gt;&lt;SPAN&gt;Since version 1 is the current version, the query returns the current contents of the table.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;Next, I make a small change to the table (for example, deleting a single row), which creates version 2. Version 1 is now a historical version rather than the current version.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;Immediately after version 2 is created, running the exact same query:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;SELECT * FROM table VERSION AS OF 1;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P class=""&gt;&lt;SPAN&gt;returns the following error:&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P class=""&gt;&lt;SPAN&gt;Cannot time travel beyond delta.deletedFileRetentionDuration (168 HOURS) set on the table.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P class=""&gt;&lt;SPAN&gt;To my knowledge, no manual &lt;/SPAN&gt;&lt;SPAN&gt;VACUUM&lt;/SPAN&gt;&lt;SPAN&gt; operation was executed. The error occurs immediately after the new version is created.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;What I find surprising is that version 1 was fully accessible while it was the current version, but as soon as a newer version is created, it becomes inaccessible because it is older than the 168-hour retention period.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;My understanding was that &lt;/SPAN&gt;&lt;SPAN&gt;delta.deletedFileRetentionDuration&lt;/SPAN&gt;&lt;SPAN&gt; controls how long deleted files are retained, and that historical versions should remain accessible unless the required files have been physically removed (for example, by a &lt;/SPAN&gt;&lt;SPAN&gt;VACUUM&lt;/SPAN&gt;&lt;SPAN&gt; operation).&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;Is this behavior expected for Unity Catalog managed tables? Are there additional settings, such as Predictive Optimization or automatic maintenance processes, that could cause this behavior even when no explicit &lt;/SPAN&gt;&lt;SPAN&gt;VACUUM&lt;/SPAN&gt;&lt;SPAN&gt; command has been run?&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;Extra information: Predictive Optimization is enabled in this catalog, but to my knowledge it doesn't run immediately after any query.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any clarification would be appreciated.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jun 2026 12:12:32 GMT</pubDate>
    <dc:creator>MVMZ</dc:creator>
    <dc:date>2026-06-16T12:12:32Z</dc:date>
    <item>
      <title>Table history time travel</title>
      <link>https://community.databricks.com/t5/data-engineering/table-history-time-travel/m-p/159150#M54793</link>
      <description>&lt;P class=""&gt;&lt;SPAN&gt;I have noticed what seems to be unexpected behavior with the history of Unity Catalog managed tables and would like to understand whether this is expected.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;As a test, I created a table with two versions:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Version 0&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Version 1 (created approximately 200 hours ago)&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;&lt;SPAN&gt;Version 1 is still the current version of the table. At this point, the following query works as expected:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;SELECT * FROM table VERSION AS OF 1;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P class=""&gt;&lt;SPAN&gt;Since version 1 is the current version, the query returns the current contents of the table.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;Next, I make a small change to the table (for example, deleting a single row), which creates version 2. Version 1 is now a historical version rather than the current version.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;Immediately after version 2 is created, running the exact same query:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;SELECT * FROM table VERSION AS OF 1;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P class=""&gt;&lt;SPAN&gt;returns the following error:&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P class=""&gt;&lt;SPAN&gt;Cannot time travel beyond delta.deletedFileRetentionDuration (168 HOURS) set on the table.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P class=""&gt;&lt;SPAN&gt;To my knowledge, no manual &lt;/SPAN&gt;&lt;SPAN&gt;VACUUM&lt;/SPAN&gt;&lt;SPAN&gt; operation was executed. The error occurs immediately after the new version is created.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;What I find surprising is that version 1 was fully accessible while it was the current version, but as soon as a newer version is created, it becomes inaccessible because it is older than the 168-hour retention period.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;My understanding was that &lt;/SPAN&gt;&lt;SPAN&gt;delta.deletedFileRetentionDuration&lt;/SPAN&gt;&lt;SPAN&gt; controls how long deleted files are retained, and that historical versions should remain accessible unless the required files have been physically removed (for example, by a &lt;/SPAN&gt;&lt;SPAN&gt;VACUUM&lt;/SPAN&gt;&lt;SPAN&gt; operation).&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;Is this behavior expected for Unity Catalog managed tables? Are there additional settings, such as Predictive Optimization or automatic maintenance processes, that could cause this behavior even when no explicit &lt;/SPAN&gt;&lt;SPAN&gt;VACUUM&lt;/SPAN&gt;&lt;SPAN&gt; command has been run?&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;Extra information: Predictive Optimization is enabled in this catalog, but to my knowledge it doesn't run immediately after any query.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any clarification would be appreciated.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2026 12:12:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/table-history-time-travel/m-p/159150#M54793</guid>
      <dc:creator>MVMZ</dc:creator>
      <dc:date>2026-06-16T12:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: Table history time travel</title>
      <link>https://community.databricks.com/t5/data-engineering/table-history-time-travel/m-p/159257#M54802</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/236301"&gt;@MVMZ&lt;/a&gt;,&lt;/P&gt;
&lt;P data-pm-slice="1 1 []"&gt;What you’re seeing is expected for Unity Catalog managed tables.&lt;/P&gt;
&lt;P&gt;The key detail is that for Unity Catalog managed tables, Databricks blocks time travel queries when the requested version is older than delta.deletedFileRetentionDuration, which is 7 days by default. This is called out in the public documentation for &lt;A href="https://docs.databricks.com/aws/en/tables/history" rel="noopener noreferrer nofollow" target="_blank"&gt;table history and time travel&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;That explains why SELECT * FROM table VERSION AS OF 1 works while version 1 is still the current version, but starts failing as soon as version 2 is created. Before version 2 exists, you are effectively reading the current table state. Once version 2 is committed, version 1 becomes a historical version, and because it is already older than 168 hours, the query is treated as a time travel request beyond the allowed retention window and is blocked immediately.&lt;/P&gt;
&lt;P&gt;So in this case, the behaviour is not dependent on whether you manually ran VACUUM. The current behaviour for Unity Catalog managed tables is that the query can be blocked based on the table’s delta.deletedFileRetentionDuration setting, even if the older files have not yet been manually cleaned up by you. The docs also explain that to query an older version successfully, Databricks needs both the log and the underlying data files for that version to still be retained, and that time travel should generally be planned around the VACUUM retention threshold.&lt;/P&gt;
&lt;P&gt;Predictive Optimization can also be relevant here, because for Unity Catalog managed tables it can automatically run VACUUM, OPTIMIZE, and ANALYZE in the background. So even if nobody explicitly issued a VACUUM command, old files can still be cleaned up automatically when &lt;A href="https://docs.databricks.com/aws/en/optimizations/predictive-optimization" rel="noopener noreferrer nofollow" target="_blank"&gt;Predictive Optimization&lt;/A&gt; is enabled.&lt;/P&gt;
&lt;P&gt;If the requirement is to keep older versions queryable for longer than 7 days, the fix is to increase delta.deletedFileRetentionDuration before relying on that history. The &lt;A href="https://docs.databricks.com/aws/en/tables/history#configure-data-retention-for-time-travel-queries" rel="noopener noreferrer nofollow" target="_blank"&gt;data retention section of the docs&lt;/A&gt; also notes that if you want, for example, 30 days of historical access, you should increase delta.deletedFileRetentionDuration accordingly, and ensure log retention is at least as long as well.&lt;/P&gt;
&lt;P class="p1"&gt;&lt;FONT size="2" color="#FF6600"&gt;&lt;STRONG&gt;&lt;I&gt;If this answer resolves your question, could you mark it as “Accept as Solution”? That helps other users quickly find the correct fix.&lt;/I&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;I&gt;&lt;/I&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2026 21:00:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/table-history-time-travel/m-p/159257#M54802</guid>
      <dc:creator>Ashwin_DSA</dc:creator>
      <dc:date>2026-06-16T21:00:48Z</dc:date>
    </item>
  </channel>
</rss>

