<?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 How to get previous version of the table in databricks sql dynamically in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-get-previous-version-of-the-table-in-databricks-sql/m-p/124249#M47149</link>
    <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;im trying to get the previous version of a delta table using timestamp but databricks sql does not allow to use variables the only thing i can do is use TIMESTAMP AS OF CURRENT_DATE() -1 if i have refreshed the table today.&lt;/P&gt;&lt;P&gt;please let me know if anyone has a better option.&lt;/P&gt;&lt;P&gt;please note i am using databricks sql as this is the only allowed language on databricks dashboard.&lt;/P&gt;</description>
    <pubDate>Mon, 07 Jul 2025 05:40:22 GMT</pubDate>
    <dc:creator>anilsampson</dc:creator>
    <dc:date>2025-07-07T05:40:22Z</dc:date>
    <item>
      <title>How to get previous version of the table in databricks sql dynamically</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-get-previous-version-of-the-table-in-databricks-sql/m-p/124249#M47149</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;im trying to get the previous version of a delta table using timestamp but databricks sql does not allow to use variables the only thing i can do is use TIMESTAMP AS OF CURRENT_DATE() -1 if i have refreshed the table today.&lt;/P&gt;&lt;P&gt;please let me know if anyone has a better option.&lt;/P&gt;&lt;P&gt;please note i am using databricks sql as this is the only allowed language on databricks dashboard.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jul 2025 05:40:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-get-previous-version-of-the-table-in-databricks-sql/m-p/124249#M47149</guid>
      <dc:creator>anilsampson</dc:creator>
      <dc:date>2025-07-07T05:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to get previous version of the table in databricks sql dynamically</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-get-previous-version-of-the-table-in-databricks-sql/m-p/124263#M47151</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/167740"&gt;@anilsampson&lt;/a&gt;&amp;nbsp;good day!&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;I believe these are the options you are try -&lt;/P&gt;&lt;P&gt;Instead of using a timestamp, you can directly reference an explicit version number in your queries. This completely avoids dynamic/deterministic date handling or any need for variables.&lt;/P&gt;&lt;P&gt;SELECT * FROM my_table VERSION AS OF &amp;lt;version_number&amp;gt;;&lt;BR /&gt;&lt;BR /&gt;or RESTORE:&lt;BR /&gt;RESTORE TABLE my_table TO VERSION AS OF &amp;lt;version_number&amp;gt;;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If you know the exact timestamp you want to use, you can hardcode this value as a literal in your query.&lt;/P&gt;&lt;P&gt;SELECT * FROM my_table TIMESTAMP AS OF '2024-07-06 16:00:00';&lt;BR /&gt;RESTORE TABLE my_table TO TIMESTAMP AS OF '2024-07-06 16:00:00';&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If your time-travel needs are simple (e.g., "give me yesterday's state"), you can use inline expressions like:&lt;/P&gt;&lt;P&gt;CURRENT_DATE() - 1&lt;BR /&gt;date_sub(current_date(), 1)&lt;BR /&gt;current_timestamp() - interval 12 hours&lt;/P&gt;&lt;P&gt;These are the only form of calculation allowed within the TIMESTAMP AS OF or RESTORE commands.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 07 Jul 2025 07:35:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-get-previous-version-of-the-table-in-databricks-sql/m-p/124263#M47151</guid>
      <dc:creator>Vidhi_Khaitan</dc:creator>
      <dc:date>2025-07-07T07:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to get previous version of the table in databricks sql dynamically</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-get-previous-version-of-the-table-in-databricks-sql/m-p/124269#M47152</link>
      <description>&lt;P&gt;thank you&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/164253"&gt;@Vidhi_Khaitan&lt;/a&gt;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;Is there an upgrade or use case in works where we can pass parameters via workflow while triggering a databricks dashboard?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jul 2025 08:57:23 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-get-previous-version-of-the-table-in-databricks-sql/m-p/124269#M47152</guid>
      <dc:creator>anilsampson</dc:creator>
      <dc:date>2025-07-07T08:57:23Z</dc:date>
    </item>
  </channel>
</rss>

