<?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 Propagating SCD2 History from Silver to Gold with AUTO CDC FLOW and Handling Full Refresh in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/propagating-scd2-history-from-silver-to-gold-with-auto-cdc-flow/m-p/172471#M56645</link>
    <description>&lt;P&gt;I have a streaming SCD2 table in the Silver layer, and I need to propagate all historical and future SCD2 events into another SCD2 streaming table in the Gold layer.&lt;/P&gt;&lt;P&gt;The Gold table is maintained through a DLT pipeline using two AUTO CDC FLOWs:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Initial history load&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Uses once=True.&lt;/LI&gt;&lt;LI&gt;Copies the entire Silver table into Gold.&lt;/LI&gt;&lt;LI&gt;This is required because the source table's CDF does not contain the complete historical event history.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Incremental updates&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Continuously reads from the Silver table's Change Data Feed (CDF).&lt;/LI&gt;&lt;LI&gt;Captures new changes as they occur.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;This setup works fine during the initial deployment:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The Silver table already contains historical SCD2 records.&lt;/LI&gt;&lt;LI&gt;The CDF is empty&lt;/LI&gt;&lt;LI&gt;The once=True flow loads all existing records into Gold.&lt;/LI&gt;&lt;LI&gt;The second flow then keeps Gold synchronized using CDF going forward.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;P&gt;&lt;STRONG&gt;The challenge appears when performing a full refresh of the Gold table.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;At that point:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The Silver table still contains the complete SCD2 history.&lt;/LI&gt;&lt;LI&gt;The Silver table's CDF&lt;STRONG&gt; now also contains some historical change events (not empty, but it does not contain full history because it has retention period).&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;If both flows are executed again:&lt;UL&gt;&lt;LI&gt;The once=True flow reloads the entire Silver table.&lt;/LI&gt;&lt;LI&gt;The incremental CDC flow replays changes from CDF.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;As a result, duplicate historical events are written into the Gold table.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Although full refreshes are expected to be rare, I'd like to have a robust solution before moving this design to production.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;P&gt;Is there a recommended Databricks pattern for handling this scenario?&amp;nbsp;&lt;SPAN&gt;Have you implemented a similar architecture using &lt;/SPAN&gt;AUTO CDC FLOW&lt;SPAN&gt; / Lakeflow Declarative Pipelines, and if so, what approach did you take?&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 09 Oct 2026 14:05:50 GMT</pubDate>
    <dc:creator>yit337</dc:creator>
    <dc:date>2026-10-09T14:05:50Z</dc:date>
    <item>
      <title>Propagating SCD2 History from Silver to Gold with AUTO CDC FLOW and Handling Full Refresh</title>
      <link>https://community.databricks.com/t5/data-engineering/propagating-scd2-history-from-silver-to-gold-with-auto-cdc-flow/m-p/172471#M56645</link>
      <description>&lt;P&gt;I have a streaming SCD2 table in the Silver layer, and I need to propagate all historical and future SCD2 events into another SCD2 streaming table in the Gold layer.&lt;/P&gt;&lt;P&gt;The Gold table is maintained through a DLT pipeline using two AUTO CDC FLOWs:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Initial history load&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Uses once=True.&lt;/LI&gt;&lt;LI&gt;Copies the entire Silver table into Gold.&lt;/LI&gt;&lt;LI&gt;This is required because the source table's CDF does not contain the complete historical event history.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Incremental updates&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Continuously reads from the Silver table's Change Data Feed (CDF).&lt;/LI&gt;&lt;LI&gt;Captures new changes as they occur.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;This setup works fine during the initial deployment:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The Silver table already contains historical SCD2 records.&lt;/LI&gt;&lt;LI&gt;The CDF is empty&lt;/LI&gt;&lt;LI&gt;The once=True flow loads all existing records into Gold.&lt;/LI&gt;&lt;LI&gt;The second flow then keeps Gold synchronized using CDF going forward.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;P&gt;&lt;STRONG&gt;The challenge appears when performing a full refresh of the Gold table.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;At that point:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The Silver table still contains the complete SCD2 history.&lt;/LI&gt;&lt;LI&gt;The Silver table's CDF&lt;STRONG&gt; now also contains some historical change events (not empty, but it does not contain full history because it has retention period).&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;If both flows are executed again:&lt;UL&gt;&lt;LI&gt;The once=True flow reloads the entire Silver table.&lt;/LI&gt;&lt;LI&gt;The incremental CDC flow replays changes from CDF.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;As a result, duplicate historical events are written into the Gold table.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Although full refreshes are expected to be rare, I'd like to have a robust solution before moving this design to production.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;P&gt;Is there a recommended Databricks pattern for handling this scenario?&amp;nbsp;&lt;SPAN&gt;Have you implemented a similar architecture using &lt;/SPAN&gt;AUTO CDC FLOW&lt;SPAN&gt; / Lakeflow Declarative Pipelines, and if so, what approach did you take?&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 09 Oct 2026 14:05:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/propagating-scd2-history-from-silver-to-gold-with-auto-cdc-flow/m-p/172471#M56645</guid>
      <dc:creator>yit337</dc:creator>
      <dc:date>2026-10-09T14:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: Propagating SCD2 History from Silver to Gold with AUTO CDC FLOW and Handling Full Refresh</title>
      <link>https://community.databricks.com/t5/data-engineering/propagating-scd2-history-from-silver-to-gold-with-auto-cdc-flow/m-p/172493#M56651</link>
      <description>&lt;P&gt;Good on you for sorting this out before production. Full refresh is exactly where the two-flow backfill pattern goes wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why the duplicates happen&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The two flows don't agree on where the history ends and the changes begin. On the first deployment the CDF happened to be empty, so the "full snapshot" and "changes since" covered different ranges without anyone setting it up that way. After a full refresh, both flows start from scratch. The once=True flow reads the whole current table. The CDF flow has a new checkpoint and replays everything still in retention. The ranges overlap and events land twice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The fix: pin both flows to the same Silver table version&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Read the Silver version once when the pipeline graph is defined, and use it as the boundary for both flows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- The once flow reads Silver as of version V (time travel), not "whatever is current".&lt;/P&gt;&lt;P&gt;- The CDF flow starts at version V and drops anything with _commit_version &amp;lt;= V.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The CDF flow's starting position only matters when its checkpoint is new. So on normal updates the once flow doesn't run again, and the CDF flow ignores the starting version and keeps going from its checkpoint. On a full refresh, both reset together and line up at the same V. Nothing overlaps and nothing goes missing, even if Silver gets writes while the refresh is running.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import dlt&lt;/P&gt;&lt;P&gt;from delta.tables import DeltaTable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SILVER = "main.silver.customer_scd2"&lt;/P&gt;&lt;P&gt;GOLD = "main.gold.customer_scd2"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Boundary version, resolved each time the graph is built.&lt;/P&gt;&lt;P&gt;# It only takes effect when the flows below start from a fresh checkpoint.&lt;/P&gt;&lt;P&gt;V = DeltaTable.forName(spark, SILVER).history(1).select("version").first()[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dlt.create_streaming_table(GOLD)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/97035"&gt;@Dlt&lt;/a&gt;.view&lt;/P&gt;&lt;P&gt;def silver_snapshot():&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; return spark.read.option("versionAsOf", V).table(SILVER)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/97035"&gt;@Dlt&lt;/a&gt;.view&lt;/P&gt;&lt;P&gt;def silver_changes():&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; return (&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; spark.readStream&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .option("readChangeFeed", "true")&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .option("startingVersion", V)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .table(SILVER)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .where(f"_commit_version &amp;gt; {V}")&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .where("_change_type IN ('insert', 'update_postimage')")&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;common = dict(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; target=GOLD,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; keys=["customer_id"],&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; sequence_by="__START_AT",&amp;nbsp; # whatever you sequence on today&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; stored_as_scd_type=2,&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dlt.create_auto_cdc_flow(name="gold_backfill", source="silver_snapshot", once=True, **common)&lt;/P&gt;&lt;P&gt;dlt.create_auto_cdc_flow(name="gold_incremental", source="silver_changes", **common)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A few notes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- I start the stream at V and filter with _commit_version &amp;gt; V rather than using startingVersion = V + 1, because V + 1 may not exist yet when the refresh starts.&lt;/P&gt;&lt;P&gt;- Keep your existing _change_type filtering and sequencing logic. The only change here is the shared boundary V.&lt;/P&gt;&lt;P&gt;- This assumes Silver is written by a different pipeline, which it sounds like it is. If Silver is in the same pipeline, you can't read its history while the graph is being built, and you'd need to pass V in as a pipeline parameter instead.&lt;/P&gt;&lt;P&gt;- Full refresh will also need the Silver snapshot at V to be readable with time travel. Since V is always the latest version, VACUUM on Silver won't get in the way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Two extra safeguards worth adding&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Set pipelines.reset.allowed = false on the Gold table so nobody can full-refresh it by accident. You can still remove the property on purpose when you really do need a rebuild.&lt;/P&gt;&lt;P&gt;- If Gold uses the same keys as Silver and only changes columns row by row, you might not need a second SCD2 engine at all. Silver already has __START_AT/__END_AT, so a materialized view or plain streaming projection over Silver keeps the history without a backfill/CDF handoff to manage. A second AUTO CDC is only worth it when Gold changes the grain or the key.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps. Feel free to share your sequence_by and _change_type handling if you'd like a second pair of eyes on the steady-state part too.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2026 16:50:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/propagating-scd2-history-from-silver-to-gold-with-auto-cdc-flow/m-p/172493#M56651</guid>
      <dc:creator>SumeshKashyap</dc:creator>
      <dc:date>2026-10-09T16:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Propagating SCD2 History from Silver to Gold with AUTO CDC FLOW and Handling Full Refresh</title>
      <link>https://community.databricks.com/t5/data-engineering/propagating-scd2-history-from-silver-to-gold-with-auto-cdc-flow/m-p/172500#M56652</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/210475"&gt;@yit337&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;The behavior you are seeing is expected. ONCE means “run once for the current pipeline state,” not “never run again.” A full refresh clears the Gold table and its flow checkpoints, so the ONCE flow runs again and the CDF flow can replay retained changes that are already included in the full snapshot.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg" data-pm-slice="1 1 []"&gt;That is why the current design can duplicate history:&lt;/P&gt;
&lt;PRE class="_1ibi0s3d4" dir="auto"&gt;&lt;CODE class="language-text"&gt;Silver snapshot  -&amp;gt; historical rows
Silver CDF       -&amp;gt; some of the same changes again
                         |
                       Gold SCD2&lt;/CODE&gt;&lt;/PRE&gt;
&lt;H2&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;The path I would recommend:&lt;/STRONG&gt;&lt;/H2&gt;
&lt;H3&gt;Preserve the original CDC events before Silver turns them into an SCD2 table.&lt;/H3&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg" data-pm-slice="1 1 []"&gt;The Bronze event table is not another SCD2 table and is not just a copy of Silver. It is an append-only log of changes, for example:&lt;/P&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg" data-pm-slice="1 1 []"&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE class="wnfdntq _1ibi0s364 _1ibi0s3ce" dir="auto"&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR dir="auto"&gt;
&lt;TH class="wnfdntt wnfdnts _1ibi0s3ac _1ibi0s39m _1ibi0s3bu _1ibi0s3b4" dir="auto" colspan="1" rowspan="1"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;sequence&lt;/P&gt;
&lt;/TH&gt;
&lt;TH class="wnfdntt wnfdnts _1ibi0s3ac _1ibi0s39m _1ibi0s3bu _1ibi0s3b4" dir="auto" colspan="1" rowspan="1"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;customer_id&lt;/P&gt;
&lt;/TH&gt;
&lt;TH class="wnfdntt wnfdnts _1ibi0s3ac _1ibi0s39m _1ibi0s3bu _1ibi0s3b4" dir="auto" colspan="1" rowspan="1"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;operation&lt;/P&gt;
&lt;/TH&gt;
&lt;TH class="wnfdntt wnfdnts _1ibi0s3ac _1ibi0s39m _1ibi0s3bu _1ibi0s3b4" dir="auto" colspan="1" rowspan="1"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;city&lt;/P&gt;
&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR dir="auto"&gt;
&lt;TD colspan="1" rowspan="1" class="wnfdntu wnfdnts _1ibi0s3ac _1ibi0s39m _1ibi0s3bu _1ibi0s3b4"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" class="wnfdntu wnfdnts _1ibi0s3ac _1ibi0s39m _1ibi0s3bu _1ibi0s3b4"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;101&lt;/P&gt;
&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" class="wnfdntu wnfdnts _1ibi0s3ac _1ibi0s39m _1ibi0s3bu _1ibi0s3b4"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;INSERT&lt;/P&gt;
&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" class="wnfdntu wnfdnts _1ibi0s3ac _1ibi0s39m _1ibi0s3bu _1ibi0s3b4"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;New York&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR dir="auto"&gt;
&lt;TD colspan="1" rowspan="1" class="wnfdntu wnfdnts _1ibi0s3ac _1ibi0s39m _1ibi0s3bu _1ibi0s3b4"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" class="wnfdntu wnfdnts _1ibi0s3ac _1ibi0s39m _1ibi0s3bu _1ibi0s3b4"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;101&lt;/P&gt;
&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" class="wnfdntu wnfdnts _1ibi0s3ac _1ibi0s39m _1ibi0s3bu _1ibi0s3b4"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;UPDATE&lt;/P&gt;
&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" class="wnfdntu wnfdnts _1ibi0s3ac _1ibi0s39m _1ibi0s3bu _1ibi0s3b4"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;San Francisco&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR dir="auto"&gt;
&lt;TD colspan="1" rowspan="1" class="wnfdntu wnfdnts _1ibi0s3ac _1ibi0s39m _1ibi0s3bu _1ibi0s3b4"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;3&lt;/P&gt;
&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" class="wnfdntu wnfdnts _1ibi0s3ac _1ibi0s39m _1ibi0s3bu _1ibi0s3b4"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;101&lt;/P&gt;
&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" class="wnfdntu wnfdnts _1ibi0s3ac _1ibi0s39m _1ibi0s3bu _1ibi0s3b4"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;UPDATE&lt;/P&gt;
&lt;/TD&gt;
&lt;TD colspan="1" rowspan="1" class="wnfdntu wnfdnts _1ibi0s3ac _1ibi0s39m _1ibi0s3bu _1ibi0s3b4"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;Los Angeles&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg" data-pm-slice="1 1 []"&gt;Each event should include:&lt;/P&gt;
&lt;UL class="wnfdntf" dir="auto"&gt;
&lt;LI class="wnfdnte _1ibi0s35c" dir="auto"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;The business key, such as customer_id&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="wnfdnte _1ibi0s35c" dir="auto"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;The operation, such as&amp;nbsp;INSERT, UPDATE, or DELETE&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="wnfdnte _1ibi0s35c" dir="auto"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;The full after-image or the changed columns&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="wnfdnte _1ibi0s35c" dir="auto"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;A source sequence, LSN, or event timestamp used to order changes&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="wnfdnte _1ibi0s35c" dir="auto"&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;Ingestion metadata&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;The important point is that Bronze retains all events and does not rewrite the old events. Silver and Gold can then both process the same complete event.&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CREATE OR REFRESH STREAMING TABLE silver_customer_history;

CREATE FLOW silver_cdc AS AUTO CDC INTO silver_customer_history
FROM STREAM(bronze_customer_events)
KEYS (customer_id)
SEQUENCE BY sequence
APPLY AS DELETE WHEN operation = 'DELETE'
COLUMNS * EXCEPT (operation, sequence)
STORED AS SCD TYPE 2;
&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;CREATE OR REFRESH STREAMING TABLE gold_customer_history;

CREATE FLOW gold_cdc AS AUTO CDC INTO gold_customer_history
FROM STREAM(bronze_customer_events)
KEYS (customer_id)
SEQUENCE BY sequence
APPLY AS DELETE WHEN operation = 'DELETE'
COLUMNS * EXCEPT (operation, sequence)
STORED AS SCD TYPE 2;
&lt;/LI-CODE&gt;
&lt;P class="p8i6j03 paragraph"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no separate ONCE=True snapshot flow in this design. A full refresh replays the complete Bronze event log once, and future updates continue from the same source. AUTO CDC is intended to process CDC feeds into SCD Type 1 or SCD Type 2 targets.&lt;/P&gt;
&lt;P&gt;CDF should not be treated as the permanent event history because it is retention-bound and may not contain the complete historical record. If CDF is the only available source, archive it continuously into a durable append-only table before retention removes it.&lt;/P&gt;
&lt;P class="p8i6j03 paragraph"&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2 class="wnfdntj wnfdnti _1ibi0s35e _1ibi0s36a" dir="auto" data-pm-slice="1 1 []"&gt;If Gold does not need independent SCD2 logic&lt;/H2&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;If Gold only needs a projection or enrichment of Silver’s existing SCD2 rows, do not apply SCD2 a second time. Use a materialized view instead:&lt;/P&gt;
&lt;PRE class="_1ibi0s3d4" dir="auto"&gt;&lt;CODE class="language-sql"&gt;CREATE OR REFRESH MATERIALIZED VIEW gold_customer AS
SELECT
  customer_id,
  city,
  __START_AT,
  __END_AT
FROM silver_customer_history;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;This avoids creating “history of history” from Silver’s CDF, which contains physical table changes such as inserts, update preimages, update postimages, and deletes, rather than necessarily representing the original business events.&lt;/P&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;One correction to the earlier example: the first SQL block should define &lt;STRONG&gt;silver_customer_history&lt;/STRONG&gt;; the second should define &lt;STRONG&gt;gold_customer_history&lt;/STRONG&gt;. Both should not define Gold.&lt;/P&gt;
&lt;P class="wnfdntw _1ibi0s3fd _1ibi0s3ce _1ibi0s3eg"&gt;If the original CDC events are not available today, this architecture requires an upstream change. The existing Silver snapshot can be used for the initial migration, but a safe full-refresh design then needs a consistent Silver version boundary so that CDF events already represented in the snapshot are not replayed.&lt;/P&gt;
&lt;P class="p8i6j03 paragraph"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2026 17:06:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/propagating-scd2-history-from-silver-to-gold-with-auto-cdc-flow/m-p/172500#M56652</guid>
      <dc:creator>adnan_alvee</dc:creator>
      <dc:date>2026-10-09T17:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: Propagating SCD2 History from Silver to Gold with AUTO CDC FLOW and Handling Full Refresh</title>
      <link>https://community.databricks.com/t5/data-engineering/propagating-scd2-history-from-silver-to-gold-with-auto-cdc-flow/m-p/172531#M56654</link>
      <description>&lt;P&gt;The cleanest fix I know is to stop treating this as two overlapping SCD2 loads. Make the two flows idempotent against each other by giving them a shared ordering domain, so a full refresh can replay both without producing duplicates.&lt;/P&gt;
&lt;H2&gt;Why you get duplicates&lt;/H2&gt;
&lt;P&gt;On a full refresh, the &lt;CODE&gt;once&lt;/CODE&gt; flow re-runs and reloads the whole Silver table [1][2]. The streaming checkpoint for the CDF flow is also reset, so it re-reads whatever CDF is still retained. Those retained events describe changes already present in the snapshot, but nothing tells Gold that. On top of that, SCD2 AUTO CDC derives its own &lt;CODE&gt;__START_AT&lt;/CODE&gt;/&lt;CODE&gt;__END_AT&lt;/CODE&gt; and its own primary key (business key plus &lt;CODE&gt;coalesce(__START_AT, __END_AT)&lt;/CODE&gt;) [3]. Feeding it data that already contains SCD2 intervals makes the same logical row land in two different shapes.&lt;/P&gt;
&lt;H2&gt;Recommended pattern: model Gold as an SCD1 table on the natural SCD2 key&lt;/H2&gt;
&lt;P&gt;A Silver SCD2 row is already uniquely identified by &lt;CODE&gt;(business_key, __START_AT)&lt;/CODE&gt;. The only thing that ever mutates on it is &lt;CODE&gt;__END_AT&lt;/CODE&gt;, when the row is closed. So you don't need AUTO CDC to build history again. Make Gold an SCD Type 1 target keyed on &lt;CODE&gt;(id, __START_AT)&lt;/CODE&gt;, which gives you the same table shape with Silver's validity columns carried through as ordinary columns.&lt;/P&gt;
&lt;P&gt;SCD1 targets support exactly the combination you need: one &lt;CODE&gt;AUTO CDC FROM SNAPSHOT&lt;/CODE&gt; flow for the backfill, plus one or more &lt;CODE&gt;AUTO CDC&lt;/CODE&gt; flows for the live feed [4]. The snapshot version and the CDC sequencing column form a single ordering domain [4]:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;A newer snapshot takes precedence over older CDC events.&lt;/LI&gt;
&lt;LI&gt;A CDC event newer than the snapshot wins over the snapshot.&lt;/LI&gt;
&lt;LI&gt;A full refresh re-runs the one-time snapshot flow [5][4].&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;So if you set the snapshot version to the Silver table version you read, and sequence the CDF flow by &lt;CODE&gt;_commit_version&lt;/CODE&gt;, then replayed CDF events at or below the snapshot version are treated as already applied and ignored. Anything committed after it is applied on top.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class="language-python"&gt;from pyspark import pipelines as dp

dp.create_streaming_table("gold_dim")

# 1) One-time history backfill, versioned by the Silver table version
def silver_snapshot(latest_version):
    if latest_version is not None:
        return None   # only ever one snapshot
    v = spark.sql("DESCRIBE HISTORY silver.dim LIMIT 1").collect()["version"]
    df = spark.read.option("versionAsOf", v).table("silver.dim")
    return df, v

dp.create_auto_cdc_from_snapshot_flow(
    target="gold_dim",
    source=silver_snapshot,
    keys=["id", "__START_AT"],
    stored_as_scd_type=1,
    once=True,
)

# 2) Live changes from Silver's CDF
@dp.view
def silver_cdf():
    return (
        spark.readStream
             .option("readChangeFeed", "true")
             .table("silver.dim")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;References&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;[1] Load and process data incrementally with Lakeflow pipeline flows | Databricks on AWS — &lt;A href="https://docs.databricks.com/aws/en/ldp/concepts/flows" target="_blank"&gt;https://docs.databricks.com/aws/en/ldp/concepts/flows&lt;/A&gt;&lt;BR /&gt;[2] AUTO CDC INTO (pipelines) | Databricks on AWS — &lt;A href="https://docs.databricks.com/aws/en/ldp/developer/ldp-sql-ref-apply-changes-into" target="_blank"&gt;https://docs.databricks.com/aws/en/ldp/developer/ldp-sql-ref-apply-changes-into&lt;/A&gt;&lt;BR /&gt;[3] Advanced AUTO CDC topics | Databricks on AWS — &lt;A href="https://docs.databricks.com/aws/en/ldp/cdc-advanced" target="_blank"&gt;https://docs.databricks.com/aws/en/ldp/cdc-advanced&lt;/A&gt;&lt;BR /&gt;[4] The AUTO CDC APIs: Simplify change data capture with pipelines | Databricks on AWS — &lt;A href="https://docs.databricks.com/aws/en/ldp/cdc" target="_blank"&gt;https://docs.databricks.com/aws/en/ldp/cdc&lt;/A&gt;&lt;BR /&gt;[5] create_auto_cdc_from_snapshot_flow | Databricks on AWS — &lt;A href="https://docs.databricks.com/aws/en/ldp/developer/ldp-python-ref-apply-changes-from-snapshot" target="_blank"&gt;https://docs.databricks.com/aws/en/ldp/developer/ldp-python-ref-apply-changes-from-snapshot&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Oct 2026 02:49:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/propagating-scd2-history-from-silver-to-gold-with-auto-cdc-flow/m-p/172531#M56654</guid>
      <dc:creator>anuj_lathi</dc:creator>
      <dc:date>2026-10-10T02:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: Propagating SCD2 History from Silver to Gold with AUTO CDC FLOW and Handling Full Refresh</title>
      <link>https://community.databricks.com/t5/data-engineering/propagating-scd2-history-from-silver-to-gold-with-auto-cdc-flow/m-p/172570#M56657</link>
      <description>&lt;DIV&gt;
&lt;P&gt;I have made a few errors in my previous response. Here's the corrected version.&lt;/P&gt;
&lt;H2&gt;What's documented about the ordering behavior&lt;/H2&gt;
&lt;P&gt;For SCD Type 1 targets, you can combine one &lt;CODE&gt;AUTO CDC FROM SNAPSHOT&lt;/CODE&gt; flow with one or more &lt;CODE&gt;AUTO CDC&lt;/CODE&gt; flows. The snapshot version and the CDC sequencing column form &lt;STRONG&gt;one ordering domain&lt;/STRONG&gt; [1]:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;A newer snapshot takes precedence over older CDC events.&lt;/LI&gt;
&lt;LI&gt;A CDC event newer than the latest snapshot takes precedence over the snapshot.&lt;/LI&gt;
&lt;LI&gt;Keys absent from the snapshot are treated as deleted at the snapshot version, though newer CDC events can restore them [1].&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;So the guarantee is precedence by version, not a separate dedup step. On a full refresh the one-time snapshot flow re-runs [1], and replayed CDF events with &lt;CODE&gt;_commit_version&lt;/CODE&gt; below the snapshot version lose to the snapshot. That is the behavior you want, because a stale "row opened, &lt;CODE&gt;__END_AT&lt;/CODE&gt; null" event must not overwrite the closed version of that row. Events at exactly the snapshot version carry the same values the snapshot already holds, so a tie is harmless under SCD1 upsert semantics.&lt;/P&gt;
&lt;H2&gt;Corrections to my earlier code&lt;/H2&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;&lt;CODE&gt;sequence_by&lt;/CODE&gt;&lt;/STRONG&gt; belongs on the CDC flow, not the snapshot flow. The snapshot flow's version is its ordering value.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;The CDF view&lt;/STRONG&gt; was never connected to a flow. It needs &lt;CODE&gt;create_auto_cdc_flow&lt;/CODE&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;&lt;CODE&gt;.collect()["version"]&lt;/CODE&gt;&lt;/STRONG&gt; was a bug. It should be &lt;CODE&gt;.collect()["version"]&lt;/CODE&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;The CDF needs cleanup.&lt;/STRONG&gt; Filter out &lt;CODE&gt;update_preimage&lt;/CODE&gt;, map deletes, and drop the CDF metadata columns.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;&lt;CODE&gt;__START_AT&lt;/CODE&gt;/&lt;CODE&gt;__END_AT&lt;/CODE&gt;&lt;/STRONG&gt; become ordinary columns because SCD1 doesn't generate or manage them. Gold just carries the values Silver computed. If you hit a naming conflict with reserved system columns (the docs flag this when adding AUTO CDC flows to an existing snapshot target [1]), rename them to &lt;CODE&gt;valid_from&lt;/CODE&gt;/&lt;CODE&gt;valid_to&lt;/CODE&gt; in the source views.&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE class="language-python"&gt;from pyspark import pipelines as dp
from pyspark.sql import functions as F

dp.create_streaming_table("gold_dim")

# One-time backfill; the snapshot version is the Silver Delta version we read
def silver_snapshot(latest_version):
    if latest_version is not None:
        return None
    v = spark.sql("DESCRIBE HISTORY silver.dim LIMIT 1").collect()["version"]
    return spark.read.option("versionAsOf", v).table("silver.dim"), v

dp.create_auto_cdc_from_snapshot_flow(
    target="gold_dim",
    source=silver_snapshot,
    keys=["id", "__START_AT"],
    stored_as_scd_type=1,&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sat, 10 Oct 2026 09:09:23 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/propagating-scd2-history-from-silver-to-gold-with-auto-cdc-flow/m-p/172570#M56657</guid>
      <dc:creator>anuj_lathi</dc:creator>
      <dc:date>2026-10-10T09:09:23Z</dc:date>
    </item>
  </channel>
</rss>

