<?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: Returing and reusing the identity value in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/returing-and-reusing-the-identity-value/m-p/80561#M36063</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/108745"&gt;@dpc&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;What you're trying to achieve does not make sense in the context of identity columns. Look at below entry from documentation. So, the answer is - if you want to have concurrent transaction, don't use identity columns &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Declaring an identity column on a Delta table disables concurrent transactions. Only use identity columns in use cases where concurrent writes to the target table are not required.&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jul 2024 12:35:50 GMT</pubDate>
    <dc:creator>szymon_dybczak</dc:creator>
    <dc:date>2024-07-25T12:35:50Z</dc:date>
    <item>
      <title>Returing and reusing the identity value</title>
      <link>https://community.databricks.com/t5/data-engineering/returing-and-reusing-the-identity-value/m-p/80547#M36059</link>
      <description>&lt;DIV&gt;&lt;SPAN&gt;Hello&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I have a table that has a column defined as an identity (BIGINT&lt;/SPAN&gt; &lt;SPAN&gt;GENERATED&lt;/SPAN&gt; &lt;SPAN&gt;ALWAYS&lt;/SPAN&gt; &lt;SPAN&gt;AS&lt;/SPAN&gt; &lt;SPAN&gt;IDENTITY)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I will be inserting rows into this table in parallel&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;How can I get the identity and use that within a pipeline&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Parallel is relevant as there will be multiple inserts passed to multiple next steps at the same time&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;e.g. workflow (multiple streams in parallel): Task 1 - insert a row; Task 2 - Insert rows into another table including the identity value from task 1; Task 3 - Insert rows into another table including the identity value from task 1 etc.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;In SQL Server, I would just insert a row and return&amp;nbsp;@@identity&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Then just pass this around using stored procedure(s)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 25 Jul 2024 12:17:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/returing-and-reusing-the-identity-value/m-p/80547#M36059</guid>
      <dc:creator>dpc</dc:creator>
      <dc:date>2024-07-25T12:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: Returing and reusing the identity value</title>
      <link>https://community.databricks.com/t5/data-engineering/returing-and-reusing-the-identity-value/m-p/80561#M36063</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/108745"&gt;@dpc&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;What you're trying to achieve does not make sense in the context of identity columns. Look at below entry from documentation. So, the answer is - if you want to have concurrent transaction, don't use identity columns &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Declaring an identity column on a Delta table disables concurrent transactions. Only use identity columns in use cases where concurrent writes to the target table are not required.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 12:35:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/returing-and-reusing-the-identity-value/m-p/80561#M36063</guid>
      <dc:creator>szymon_dybczak</dc:creator>
      <dc:date>2024-07-25T12:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Returing and reusing the identity value</title>
      <link>https://community.databricks.com/t5/data-engineering/returing-and-reusing-the-identity-value/m-p/80582#M36073</link>
      <description>&lt;P&gt;Thanks Slash&lt;/P&gt;&lt;P&gt;In this case though, the batch generation is not concurrent, it's sequential but the full batch running can be concurrent (if that makes sense)&lt;/P&gt;&lt;P&gt;So, I could be running 5 batches in parallel (not necessarily starting at the same time) and all 5 generate a different id.&lt;/P&gt;&lt;P&gt;The batches can differ in terms of what they do but the key here is that, where required, they record the batch id that's relevant to their batch - so the id is recorded consistently (any table writes where needed) throughout&lt;/P&gt;&lt;P&gt;There are some suggestions elsewhere that you can generate one, then just read the last batch id&lt;/P&gt;&lt;P&gt;That wouldn't work here&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 14:52:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/returing-and-reusing-the-identity-value/m-p/80582#M36073</guid>
      <dc:creator>dpc</dc:creator>
      <dc:date>2024-07-25T14:52:07Z</dc:date>
    </item>
  </channel>
</rss>

