<?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 duplicate data published in kafka offset in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/duplicate-data-published-in-kafka-offset/m-p/96666#M8647</link>
    <description>&lt;P&gt;we have 25k data which are publishing by batch of 5k.&lt;/P&gt;&lt;P&gt;we are numbering the records based on row_number window function and creating batch using this.&lt;/P&gt;&lt;P&gt;we have observed that some records like 10-20 records are getting published duplicated in 2 offset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;can someone help with the probable cause for this issue.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Oct 2024 14:24:37 GMT</pubDate>
    <dc:creator>dipali_globant</dc:creator>
    <dc:date>2024-10-29T14:24:37Z</dc:date>
    <item>
      <title>duplicate data published in kafka offset</title>
      <link>https://community.databricks.com/t5/get-started-discussions/duplicate-data-published-in-kafka-offset/m-p/96666#M8647</link>
      <description>&lt;P&gt;we have 25k data which are publishing by batch of 5k.&lt;/P&gt;&lt;P&gt;we are numbering the records based on row_number window function and creating batch using this.&lt;/P&gt;&lt;P&gt;we have observed that some records like 10-20 records are getting published duplicated in 2 offset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;can someone help with the probable cause for this issue.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 14:24:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/duplicate-data-published-in-kafka-offset/m-p/96666#M8647</guid>
      <dc:creator>dipali_globant</dc:creator>
      <dc:date>2024-10-29T14:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: duplicate data published in kafka offset</title>
      <link>https://community.databricks.com/t5/get-started-discussions/duplicate-data-published-in-kafka-offset/m-p/96674#M8648</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/130149"&gt;@dipali_globant&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;duplicate data in Kafka can arise in a batch processing scenario for a few reasons &lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/P&gt;&lt;P&gt;here’s an example of ensuring unique and consistent row numbering:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pyspark.sql import Window
from pyspark.sql.functions import row_number

window_spec = Window.orderBy("unique_column")  # Replace "unique_column" with a reliable ordering column

df = df.withColumn("row_number", row_number().over(window_spec))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The ROW_NUMBER window function may assign different row numbers across batch executions if there’s no consistent order. This can result in the same records being included in multiple batches, especially if partitions or order change between runs, so you can use a specific column or combination of columns for ordering that is unique and stable (such as timestamps or primary keys).&lt;/P&gt;&lt;P&gt;If you are processing and publishing multiple batches simultaneously, concurrency issues could arise, especially if some data falls between two consecutive batch windows.&lt;/P&gt;&lt;P&gt;check and comments!&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 15:54:34 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/duplicate-data-published-in-kafka-offset/m-p/96674#M8648</guid>
      <dc:creator>agallard</dc:creator>
      <dc:date>2024-10-29T15:54:34Z</dc:date>
    </item>
  </channel>
</rss>

