<?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 Re: Databricks SDP (Spark declarative Pipelins) Overwrite table in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/databricks-sdp-spark-declarative-pipelins-overwrite-table/m-p/170552#M56317</link>
    <description>&lt;P&gt;Streaming tables are append-only by design, so they can't overwrite. Use a materialized view that keeps only the rows from the newest file, via the _metadata column:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sql&lt;/P&gt;&lt;P&gt;CREATE OR REFRESH MATERIALIZED VIEW orders AS&lt;/P&gt;&lt;P&gt;SELECT * EXCEPT (file_time)&lt;/P&gt;&lt;P&gt;FROM (&lt;/P&gt;&lt;P&gt;&amp;nbsp; SELECT *,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;_metadata.file_modification_time AS file_time&lt;/P&gt;&lt;P&gt;&amp;nbsp; FROM read_files('/path/orders/', format =&amp;gt; 'csv', header =&amp;gt; true)&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;QUALIFY file_time = MAX(file_time) OVER ();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each refresh then replaces the table contents with only the latest file (orders_2.csv, then orders_3.csv, and so on).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the folder grows large, ingest with a streaming table (Auto Loader) into a bronze table, storing _metadata.file_name and _metadata.file_modification_time as columns, and build the same "latest file only" materialized view on top of it. That way all the files aren't re-read on every refresh.&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;</description>
    <pubDate>Sun, 04 Oct 2026 16:16:50 GMT</pubDate>
    <dc:creator>SumeshKashyap</dc:creator>
    <dc:date>2026-10-04T16:16:50Z</dc:date>
    <item>
      <title>Databricks SDP (Spark declarative Pipelins) Overwrite table</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-sdp-spark-declarative-pipelins-overwrite-table/m-p/170550#M56316</link>
      <description>&lt;DIV&gt;1) Consider I have orders folder which orders_1.csv file&amp;nbsp; and it is loaded to orders tables&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;orders/&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;============&amp;gt; load to order table&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;orders_1.csv&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;2)&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;next day new file (orders_2.csv) arrived&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;orders/&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;=========&amp;gt; take only 2nd file -----&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;overwrite the order table&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;orders_1.csv&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; orders_2.csv&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Here streaming table only appending the data to orders table.&amp;nbsp; Materialized view is considering both files. &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;My requirement is overwrite the orders table.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Can you help me how to do that ??&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 04 Oct 2026 15:21:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-sdp-spark-declarative-pipelins-overwrite-table/m-p/170550#M56316</guid>
      <dc:creator>pvrcloudtech</dc:creator>
      <dc:date>2026-10-04T15:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: Databricks SDP (Spark declarative Pipelins) Overwrite table</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-sdp-spark-declarative-pipelins-overwrite-table/m-p/170552#M56317</link>
      <description>&lt;P&gt;Streaming tables are append-only by design, so they can't overwrite. Use a materialized view that keeps only the rows from the newest file, via the _metadata column:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sql&lt;/P&gt;&lt;P&gt;CREATE OR REFRESH MATERIALIZED VIEW orders AS&lt;/P&gt;&lt;P&gt;SELECT * EXCEPT (file_time)&lt;/P&gt;&lt;P&gt;FROM (&lt;/P&gt;&lt;P&gt;&amp;nbsp; SELECT *,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;_metadata.file_modification_time AS file_time&lt;/P&gt;&lt;P&gt;&amp;nbsp; FROM read_files('/path/orders/', format =&amp;gt; 'csv', header =&amp;gt; true)&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;QUALIFY file_time = MAX(file_time) OVER ();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each refresh then replaces the table contents with only the latest file (orders_2.csv, then orders_3.csv, and so on).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the folder grows large, ingest with a streaming table (Auto Loader) into a bronze table, storing _metadata.file_name and _metadata.file_modification_time as columns, and build the same "latest file only" materialized view on top of it. That way all the files aren't re-read on every refresh.&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Sun, 04 Oct 2026 16:16:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-sdp-spark-declarative-pipelins-overwrite-table/m-p/170552#M56317</guid>
      <dc:creator>SumeshKashyap</dc:creator>
      <dc:date>2026-10-04T16:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: Databricks SDP (Spark declarative Pipelins) Overwrite table</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-sdp-spark-declarative-pipelins-overwrite-table/m-p/170554#M56318</link>
      <description>&lt;P&gt;A Streaming Table may not be the right fit for this requirement. It is designed to process new files incrementally, so when &lt;STRONG&gt;orders2.csv&amp;nbsp;&lt;/STRONG&gt;arrives, it will append the new data.&lt;/P&gt;&lt;P&gt;If each new file is a full snapshot and should completely replace the previous data, you can use a batch job to read only the latest file and overwrite the target Delta table using:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;df.write.mode("overwrite").saveAsTable("orders")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Another option is to keep only the latest file in a&amp;nbsp; &lt;STRONG&gt;current&lt;/STRONG&gt;/ folder and move older files to an &lt;STRONG&gt;archive&lt;/STRONG&gt;/ folder.&lt;/P&gt;&lt;P&gt;So in this case, I would prefer a batch overwrite approach rather than a Streaming Table.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Oct 2026 16:25:25 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-sdp-spark-declarative-pipelins-overwrite-table/m-p/170554#M56318</guid>
      <dc:creator>vannurswamy</dc:creator>
      <dc:date>2026-10-04T16:25:25Z</dc:date>
    </item>
  </channel>
</rss>

