<?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: Handling Dropped Records in Delta Live Tables with Watermark - Need Optimization Strategy in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/handling-dropped-records-in-delta-live-tables-with-watermark/m-p/103067#M41327</link>
    <description>&lt;P class=""&gt;Dear&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/88823"&gt;@Walter_C&lt;/a&gt;,&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/34618"&gt;@VZLA&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P class=""&gt;I hope this topic finds you well. I'm following up on the technical issues I submitted last week that remains unresolved. This issue has become our team's most significant blocker, preventing us from progressing with our project implementation.&lt;/P&gt;&lt;P class=""&gt;We greatly value your expertise and would deeply appreciate your guidance on this matter. Given the critical nature of this blocker, any insights you could provide would be immensely helpful in moving our project forward.&lt;/P&gt;&lt;P class=""&gt;Please let me know if you need any additional information from our side to assist with the resolution.&lt;/P&gt;&lt;P class=""&gt;Thank you for your time and attention to this matter.&lt;BR /&gt;&lt;BR /&gt;Best regards.&lt;/P&gt;</description>
    <pubDate>Tue, 24 Dec 2024 03:40:11 GMT</pubDate>
    <dc:creator>minhhung0507</dc:creator>
    <dc:date>2024-12-24T03:40:11Z</dc:date>
    <item>
      <title>Handling Dropped Records in Delta Live Tables with Watermark - Need Optimization Strategy</title>
      <link>https://community.databricks.com/t5/data-engineering/handling-dropped-records-in-delta-live-tables-with-watermark/m-p/102613#M41179</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi Databricks Community,&lt;/SPAN&gt;&lt;SPAN&gt;I'm encountering an issue with watermarks in Delta Live Tables that's causing data loss in my streaming pipeline. Let me explain my specific problem:&lt;/SPAN&gt;&lt;/P&gt;&lt;H2&gt;Current Situation&lt;/H2&gt;&lt;P&gt;&lt;SPAN&gt;I've implemented watermarks for stateful processing in my Delta Live Tables pipeline. However, I'm observing that some records are being dropped, as evidenced by the monitoring graphs I've attached. The graphs show:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL class=""&gt;&lt;LI&gt;&lt;SPAN&gt;Spikes in the number of late rows dropped by watermark&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;One graph shows a peak of around 20 records dropped&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Another graph displays multiple peaks with up to 250 records being dropped&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;H2&gt;Questions&lt;/H2&gt;&lt;OL class=""&gt;&lt;LI&gt;&lt;SPAN&gt;What are the recommended strategies to optimize watermark configuration to minimize data loss while maintaining processing efficiency?&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Is there a way to:&lt;/SPAN&gt;&lt;UL class=""&gt;&lt;LI&gt;&lt;SPAN&gt;Capture these dropped records for later processing?&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Implement a recovery mechanism to reprocess these dropped records?&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Update the final table with these recovered records without causing duplicates or inconsistencies?&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;H2&gt;Additional Context&lt;/H2&gt;&lt;P&gt;&lt;SPAN&gt;I understand that watermarks are essential for managing state and preventing out-of-memory issues, but I need to ensure data completeness for my use case. Any guidance on best practices or alternative approaches would be greatly appreciated.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Dec 2024 06:54:01 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/handling-dropped-records-in-delta-live-tables-with-watermark/m-p/102613#M41179</guid>
      <dc:creator>minhhung0507</dc:creator>
      <dc:date>2024-12-19T06:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: Handling Dropped Records in Delta Live Tables with Watermark - Need Optimization Strategy</title>
      <link>https://community.databricks.com/t5/data-engineering/handling-dropped-records-in-delta-live-tables-with-watermark/m-p/102642#M41190</link>
      <description>&lt;P&gt;The watermark threshold determines how late data can be before it is considered too late and dropped. A smaller threshold results in lower latency but increases the likelihood of dropping late records. Conversely, a larger threshold reduces data loss but may increase latency and require more resources&lt;/P&gt;
&lt;P&gt;Continuously monitor your streaming pipeline to understand the patterns of late data and adjust the watermark threshold accordingly. This can help balance between latency and data completeness.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;To capture records that are dropped due to being late, you can use the &lt;CODE&gt;withEventTimeOrder&lt;/CODE&gt; option. This ensures that the initial snapshot is processed in event time order, reducing the likelihood of records being dropped as late events.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="gb5fhw2"&gt;
&lt;PRE&gt;&lt;CODE class="markdown-code-python _1t7bu9hb hljs language-python gb5fhw3"&gt;.option(&lt;SPAN class="hljs-string"&gt;"withEventTimeOrder"&lt;/SPAN&gt;, &lt;SPAN class="hljs-string"&gt;"true"&lt;/SPAN&gt;)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;SPAN&gt;You can implement a recovery mechanism by storing the dropped records in a separate Delta table for later processing. This can be achieved by configuring your streaming query to write late records to a different sink.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Dec 2024 11:37:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/handling-dropped-records-in-delta-live-tables-with-watermark/m-p/102642#M41190</guid>
      <dc:creator>Walter_C</dc:creator>
      <dc:date>2024-12-19T11:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Handling Dropped Records in Delta Live Tables with Watermark - Need Optimization Strategy</title>
      <link>https://community.databricks.com/t5/data-engineering/handling-dropped-records-in-delta-live-tables-with-watermark/m-p/102744#M41222</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Dear&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/88823"&gt;@Walter_C&lt;/a&gt;, t&lt;/SPAN&gt;&lt;SPAN&gt;hank you for your detailed response regarding watermark handling in Delta Live Tables (DLT). I appreciate the guidance provided, but I would like further clarification on a couple of points related to our use case.&lt;/SPAN&gt;&lt;/P&gt;&lt;H2&gt;1. Auto-Saving Dropped Records Due to Watermark&lt;/H2&gt;&lt;P&gt;&lt;SPAN&gt;We are currently using the&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;APPLY CHANGES&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;API in Delta Live Tables for our pipeline. Is there a built-in mechanism or recommended approach to automatically save records that are dropped due to watermark thresholds? Specifically, we are looking for:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL class=""&gt;&lt;LI&gt;&lt;SPAN&gt;Step-by-step guidelines or documentation on how to implement this functionality.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Code examples or configurations that demonstrate how to capture these late records into a separate Delta table for later processing.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;If this is not natively supported, could you recommend an alternative approach to achieve this while maintaining pipeline efficiency?&lt;/SPAN&gt;&lt;/P&gt;&lt;H2&gt;2. Auto-Triggering Updates for Dropped Records&lt;/H2&gt;&lt;P&gt;&lt;SPAN&gt;Once the dropped records are saved, we aim to reprocess them and update the final table automatically. Could you provide guidance on:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL class=""&gt;&lt;LI&gt;&lt;SPAN&gt;How to design a recovery mechanism that triggers updates for these saved records without manual intervention?&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;The best practices to ensure these updates do not introduce duplicates or inconsistencies in the final table.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Any optimizations we can apply to minimize resource usage and processing time during this recovery process.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;We would greatly appreciate any additional insights or references to best practices for managing late-arriving data in DLT pipelines.&lt;/SPAN&gt;&lt;SPAN&gt;Looking forward to your response!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2024 04:00:35 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/handling-dropped-records-in-delta-live-tables-with-watermark/m-p/102744#M41222</guid>
      <dc:creator>minhhung0507</dc:creator>
      <dc:date>2024-12-20T04:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Handling Dropped Records in Delta Live Tables with Watermark - Need Optimization Strategy</title>
      <link>https://community.databricks.com/t5/data-engineering/handling-dropped-records-in-delta-live-tables-with-watermark/m-p/103067#M41327</link>
      <description>&lt;P class=""&gt;Dear&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/88823"&gt;@Walter_C&lt;/a&gt;,&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/34618"&gt;@VZLA&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P class=""&gt;I hope this topic finds you well. I'm following up on the technical issues I submitted last week that remains unresolved. This issue has become our team's most significant blocker, preventing us from progressing with our project implementation.&lt;/P&gt;&lt;P class=""&gt;We greatly value your expertise and would deeply appreciate your guidance on this matter. Given the critical nature of this blocker, any insights you could provide would be immensely helpful in moving our project forward.&lt;/P&gt;&lt;P class=""&gt;Please let me know if you need any additional information from our side to assist with the resolution.&lt;/P&gt;&lt;P class=""&gt;Thank you for your time and attention to this matter.&lt;BR /&gt;&lt;BR /&gt;Best regards.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2024 03:40:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/handling-dropped-records-in-delta-live-tables-with-watermark/m-p/103067#M41327</guid>
      <dc:creator>minhhung0507</dc:creator>
      <dc:date>2024-12-24T03:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Handling Dropped Records in Delta Live Tables with Watermark - Need Optimization Strategy</title>
      <link>https://community.databricks.com/t5/data-engineering/handling-dropped-records-in-delta-live-tables-with-watermark/m-p/103140#M41346</link>
      <description>&lt;P&gt;&lt;STRONG&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/135091"&gt;@minhhung0507&lt;/a&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Short Answer; This requires custom design implementation:&lt;/STRONG&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;DLT does not natively “auto-save” records dropped by watermark. You must configure a secondary output or pipeline to capture potentially late records (e.g., ingest the same source with a more permissive watermark or no watermark at all).&lt;/LI&gt;
&lt;LI&gt;Once saved, reprocess those late records with &lt;CODE&gt;APPLY CHANGES&lt;/CODE&gt; (or a merge-based approach) into your main table. Use a unique key and the &lt;CODE&gt;DEDUPLICATE ON&lt;/CODE&gt; clause to avoid duplicates.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;STRONG&gt;Details (Example):&lt;/STRONG&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Capturing Dropped Records&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Separate “Late Events” Table&lt;/STRONG&gt;: Create a second DLT table reading from the same source but with a more relaxed watermark (or no watermark) to capture events that arrive after the main pipeline’s cutoff. This effectively quarantines all potential late events.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Example&lt;/STRONG&gt;:
&lt;DIV class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950"&gt;
&lt;DIV class="sticky top-9 md:top-[5.75rem]"&gt;
&lt;DIV class="absolute bottom-0 right-2 flex h-9 items-center"&gt;
&lt;DIV class="flex items-center rounded bg-token-sidebar-surface-primary px-2 font-sans text-xs text-token-text-secondary dark:bg-token-main-surface-secondary"&gt;&lt;LI-CODE lang="markup"&gt;CREATE STREAMING LIVE TABLE late_events
AS SELECT * 
FROM STREAM(live.source_data)
-- Optionally set a larger watermark or omit it here&lt;/LI-CODE&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="overflow-y-auto p-4" dir="ltr"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Why&lt;/STRONG&gt;: DLT itself does not offer a built-in “auto-save dropped records” feature, so this extra DLT table prevents data loss and isolates potentially late data.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Reprocessing &amp;amp; Updating the Final Table&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Use APPLY CHANGES&lt;/STRONG&gt;: Point it to both your main input table and the late events table—either in the same pipeline or in a separate “cleanup” pipeline.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Example&lt;/STRONG&gt;:
&lt;DIV class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950"&gt;
&lt;DIV class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none"&gt;&lt;LI-CODE lang="markup"&gt;APPLY CHANGES INTO live.final_table
  FROM STREAM(live.late_events)
  KEYS (id)
  SEQUENCE BY event_time
  DEDUPLICATE ON (id)
  WHEN NOT MATCHED THEN INSERT *
  WHEN MATCHED THEN UPDATE SET *&lt;/LI-CODE&gt;&lt;/DIV&gt;
&lt;DIV class="overflow-y-auto p-4" dir="ltr"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Deduplication&lt;/STRONG&gt;: Rely on a unique key (&lt;CODE&gt;id&lt;/CODE&gt;) plus &lt;CODE&gt;DEDUPLICATE ON&lt;/CODE&gt; to avoid duplicates when reprocessing late arrivals.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Auto-Triggering Updates&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Incremental Pipeline&lt;/STRONG&gt;: Schedule a job to process the quarantined late_events table on a periodic basis. This way, any new late arrivals automatically flow in.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Best Practice&lt;/STRONG&gt;: Keep your main pipeline’s watermark at a balanced threshold for normal loads. Let the “late events” pipeline handle stragglers in batches to avoid ballooning resource usage.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Efficiency Tips&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Monitoring&lt;/STRONG&gt;: Track late arrivals in the “late_events” table. If volumes are consistently high, you may need to adjust your main pipeline’s watermark, so this is a great benefit.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Resource Usage&lt;/STRONG&gt;: Keep your “late events” pipeline idle between scheduled runs if possible, minimizing overhead and costs.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;By splitting your pipeline into “on-time processing” (with a reasonable watermark) and “late-arrivals handling” (with no/loose watermark), you ensure minimal data loss and an automated path to reconcile late records without duplications.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;But...&lt;/STRONG&gt; Having said that, simply extending the watermark might still be the simplest solution—provided the use case can handle the increased state and potential higher latency.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Questions and considerations you should consider:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Frequency of Late Events&lt;/STRONG&gt;: How common are these late arrivals? If they’re rare, slightly extending the watermark might be enough.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Resource Constraints&lt;/STRONG&gt;: Can your cluster handle the extra memory overhead of a larger watermark window?&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Acceptable Latency&lt;/STRONG&gt;: If you extend the watermark, are you prepared for a longer overall processing delay?&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Downstream Impact&lt;/STRONG&gt;: Will delaying your final table updates to accommodate out-of-order data create downstream bottlenecks?&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Business Requirements&lt;/STRONG&gt;: Do you actually need 100% completeness in near real-time, or can later arrived records be reconciled less frequently?&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;These questions help decide if adjusting the watermark alone addresses your needs or if you truly need a more involved multi-pipeline approach.&lt;/P&gt;
&lt;P&gt;Hope this is helpful. Please remember to follow common best practices and test it in a development environment before deploying it in production; this is not a trivial change.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2024 13:57:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/handling-dropped-records-in-delta-live-tables-with-watermark/m-p/103140#M41346</guid>
      <dc:creator>VZLA</dc:creator>
      <dc:date>2024-12-24T13:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Handling Dropped Records in Delta Live Tables with Watermark - Need Optimization Strategy</title>
      <link>https://community.databricks.com/t5/data-engineering/handling-dropped-records-in-delta-live-tables-with-watermark/m-p/103167#M41353</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dear&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/34618"&gt;@VZLA&lt;/a&gt;,&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/88823"&gt;@Walter_C&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I wanted to take a moment to express my sincere gratitude for your incredibly detailed explanation and thoughtful suggestions. Your guidance has been immensely valuable and has provided us with a clear path forward in addressing the challenge with late-arriving records in DLT.&lt;/P&gt;&lt;P&gt;We’ve decided to adopt the approach you recommended, including implementing a secondary pipeline to handle late events. The clarity and depth of your explanation have given us great confidence in the solution, and we truly appreciate the time and effort you’ve put into sharing your expertise.&lt;/P&gt;&lt;P&gt;Once again, thank you so much for your invaluable support.&lt;/P&gt;&lt;P&gt;Best regards,&lt;BR /&gt;Hung.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Dec 2024 03:51:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/handling-dropped-records-in-delta-live-tables-with-watermark/m-p/103167#M41353</guid>
      <dc:creator>minhhung0507</dc:creator>
      <dc:date>2024-12-25T03:51:37Z</dc:date>
    </item>
  </channel>
</rss>

