<?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: How does AUTO CDC resolve same-timestamp tie in SEQUENCE BY? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-does-auto-cdc-resolve-same-timestamp-tie-in-sequence-by/m-p/168550#M55940</link>
    <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/249065"&gt;@Khasim_1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested this with a small AUTO CDC pipeline and SEQUENCE BY STRUCT() works as expected for same-timestamp ties.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Eg:&amp;nbsp;&lt;/STRONG&gt;In below data&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Event_ts  seq_id operation
12:00     seq=1  INSERT
12:10     seq=1  UPDATE
12:10     seq=2  DELETE&lt;/LI-CODE&gt;&lt;P&gt;with&amp;nbsp;sequence_by=struct("event_ts", "seq_id"),&amp;nbsp;the second field is used as the tie-breaker, so (12:10, 2) is considered later than (12:10, 1).&lt;/P&gt;&lt;P&gt;In my test with SCD Type 1, the final target row was removed because the latest logical event was the DELETE. The source CDC table still retained all events, the target represented only the latest state.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Summary:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Out-of-order arrival -&amp;gt; AUTO CDC handles this through SEQUENCE BY.&lt;/LI&gt;&lt;LI&gt;Same timestamp ties -&amp;gt; use STRUCT(timestamp, secondary_sequence).&lt;/LI&gt;&lt;LI&gt;No reliable secondary sequence from source -&amp;gt; add a pre-processing step: staging/dedup before AUTO CDC.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I’d also avoid assuming that AUTO CDC gives DELETE or UPDATE any priority when their sequence values are identical. Use an explicit tie-breaker so the event order is deterministic.&lt;/P&gt;</description>
    <pubDate>Mon, 14 Sep 2026 16:00:26 GMT</pubDate>
    <dc:creator>data_pulse</dc:creator>
    <dc:date>2026-09-14T16:00:26Z</dc:date>
    <item>
      <title>How does AUTO CDC resolve same-timestamp tie in SEQUENCE BY?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-does-auto-cdc-resolve-same-timestamp-tie-in-sequence-by/m-p/168486#M55927</link>
      <description>&lt;P&gt;We are using AUTO CDC (APPLY CHANGES INTO) to process change data capture events from an upstream source (via Autoloader ingesting CDC files landed in cloud storage) into our Silver layer tables. Our source occasionally delivers out-of-order events — i.e., an UPDATE event can arrive before its corresponding INSERT, or a later-timestamped DELETE can arrive before an earlier UPDATE due to upstream retry/replay logic. &amp;gt; &amp;gt; We are using the SEQUENCE BY clause with our event timestamp column, but we occasionally still see records where the final state in the target table doesn't reflect the "true" latest state — we suspect this happens when duplicate timestamps exist across different event types (INSERT/UPDATE/DELETE) for the same key.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;When multiple CDC events for the same key have identical SEQUENCE BY timestamps but different operation types (e.g., UPDATE and DELETE with the same timestamp), how does AUTO CDC resolve the tie internally? Is there a documented precedence order (e.g., DELETE always wins over UPDATE at the same timestamp)?&lt;/LI&gt;&lt;LI&gt;Is there a way to specify a secondary sequencing column (similar to a tie-breaker in a ROW_NUMBER() window function) to deterministically resolve same-timestamp conflicts in APPLY CHANGES INTO?&lt;/LI&gt;&lt;LI&gt;What's the recommended approach for handling truly out-of-order arrival (not just same-timestamp ties) — should we be doing pre-deduplication/sorting in a Bronze-to-Silver staging step before applying AUTO CDC, or does the framework already handle this natively as long as SEQUENCE BY is correctly set? &amp;gt; &amp;gt; Would appreciate any real-world experiences or documentation pointers on handling these edge cases reliably in production CDC pipelines.&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Sun, 13 Sep 2026 17:48:34 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-does-auto-cdc-resolve-same-timestamp-tie-in-sequence-by/m-p/168486#M55927</guid>
      <dc:creator>Khasim_1</dc:creator>
      <dc:date>2026-09-13T17:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: How does AUTO CDC resolve same-timestamp tie in SEQUENCE BY?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-does-auto-cdc-resolve-same-timestamp-tie-in-sequence-by/m-p/168535#M55939</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/249065"&gt;@Khasim_1&lt;/a&gt;, I would suggest not relying only on the timestamp if duplicate timestamps are possible. AUTO CDC can handle out-of-order events using SEQUENCE BY, but the sequencing should be deterministic.&lt;/P&gt;&lt;P&gt;You could try SEQUENCE BY STRUCT(event_timestamp, event_sequence_id) so the second field acts as a tie-breaker. If the source does not provide a reliable sequence or event ID, a small Bronze staging step to resolve those conflicts before AUTO CDC may be safer.&lt;/P&gt;&lt;P&gt;Hope this helps!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Brahma&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2026 13:50:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-does-auto-cdc-resolve-same-timestamp-tie-in-sequence-by/m-p/168535#M55939</guid>
      <dc:creator>Brahmareddy</dc:creator>
      <dc:date>2026-09-14T13:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: How does AUTO CDC resolve same-timestamp tie in SEQUENCE BY?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-does-auto-cdc-resolve-same-timestamp-tie-in-sequence-by/m-p/168550#M55940</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/249065"&gt;@Khasim_1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested this with a small AUTO CDC pipeline and SEQUENCE BY STRUCT() works as expected for same-timestamp ties.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Eg:&amp;nbsp;&lt;/STRONG&gt;In below data&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Event_ts  seq_id operation
12:00     seq=1  INSERT
12:10     seq=1  UPDATE
12:10     seq=2  DELETE&lt;/LI-CODE&gt;&lt;P&gt;with&amp;nbsp;sequence_by=struct("event_ts", "seq_id"),&amp;nbsp;the second field is used as the tie-breaker, so (12:10, 2) is considered later than (12:10, 1).&lt;/P&gt;&lt;P&gt;In my test with SCD Type 1, the final target row was removed because the latest logical event was the DELETE. The source CDC table still retained all events, the target represented only the latest state.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Summary:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Out-of-order arrival -&amp;gt; AUTO CDC handles this through SEQUENCE BY.&lt;/LI&gt;&lt;LI&gt;Same timestamp ties -&amp;gt; use STRUCT(timestamp, secondary_sequence).&lt;/LI&gt;&lt;LI&gt;No reliable secondary sequence from source -&amp;gt; add a pre-processing step: staging/dedup before AUTO CDC.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I’d also avoid assuming that AUTO CDC gives DELETE or UPDATE any priority when their sequence values are identical. Use an explicit tie-breaker so the event order is deterministic.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2026 16:00:26 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-does-auto-cdc-resolve-same-timestamp-tie-in-sequence-by/m-p/168550#M55940</guid>
      <dc:creator>data_pulse</dc:creator>
      <dc:date>2026-09-14T16:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: How does AUTO CDC resolve same-timestamp tie in SEQUENCE BY?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-does-auto-cdc-resolve-same-timestamp-tie-in-sequence-by/m-p/168561#M55942</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/249065"&gt;@Khasim_1&lt;/a&gt;&amp;nbsp;on your third question, check &lt;STRONG&gt;delete-tombstone retention&lt;/STRONG&gt; alongside the sequencing change. &lt;U&gt;&lt;STRONG&gt;The default is two days&lt;/STRONG&gt;&lt;/U&gt;. The &lt;A href="https://docs.databricks.com/aws/en/ldp/developer/ldp-python-ref-apply-changes" target="_blank" rel="noopener"&gt;create_auto_cdc_flow reference&lt;/A&gt; gives this instruction:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Set &lt;EM&gt;pipelines.cdc.tombstoneGCThresholdInSeconds&lt;/EM&gt; to a value that exceeds the maximum expected delay between event arrival and pipeline execution.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This is a &lt;STRONG&gt;target table property&lt;/STRONG&gt;. I’d include outage recovery and replay backlogs when estimating that delay, not just normal processing time.&lt;/P&gt;&lt;P&gt;The &lt;A href="https://docs.databricks.com/aws/en/ldp/cdc#auto-cdc-examples" target="_blank" rel="noopener"&gt;AUTO CDC examples&lt;/A&gt; show the relevant behavior for &lt;EM&gt;userId = 123&lt;/EM&gt;:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Event&lt;/TD&gt;&lt;TD&gt;&lt;EM&gt;sequenceNum&lt;/EM&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Initial insert&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Delete&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Update arriving out of order&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;With delete handling configured, the documented results are:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;SCD1:&lt;/STRONG&gt; user &lt;EM&gt;123&lt;/EM&gt; remains absent.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;SCD2:&lt;/STRONG&gt; the history contains versions with &lt;EM&gt;__START_AT&lt;/EM&gt; / &lt;EM&gt;__END_AT&lt;/EM&gt; values of &lt;EM&gt;1&lt;/EM&gt; / &lt;EM&gt;5&lt;/EM&gt; and &lt;EM&gt;5&lt;/EM&gt; / &lt;EM&gt;6&lt;/EM&gt;. Neither is active, so the earlier update does not undo the later delete.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;That example demonstrates event ordering, not what happens after tombstone expiry. For your pipeline, I'd test the same sequence across separate batches within the configured retention window. This checks late-arrival handling alongside the tie-breaking fix.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2026 18:30:01 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-does-auto-cdc-resolve-same-timestamp-tie-in-sequence-by/m-p/168561#M55942</guid>
      <dc:creator>ivanvyd</dc:creator>
      <dc:date>2026-09-14T18:30:01Z</dc:date>
    </item>
  </channel>
</rss>

