<?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 IDENTITY column duplication when using BY DEFAULT parameter in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/identity-column-duplication-when-using-by-default-parameter/m-p/31567#M22999</link>
    <description>&lt;P&gt;Hi, I created delta table with identity column using this syntax:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Id BIGINT GENERATED BY DEFAULT AS IDENTITY&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My steps:&lt;/P&gt;&lt;P&gt;1) Created table with Id using syntax above.&lt;/P&gt;&lt;P&gt;2) Added two rows with Id = 1 and Id = 2 (BY DEFAULT allows to do that).&lt;/P&gt;&lt;P&gt;3) Run Insert (without specifying Id column)&lt;/P&gt;&lt;P&gt;My result:&lt;/P&gt;&lt;P&gt;I have duplicated Id's:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image.png"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1486iDFA56DAFC22DB29F/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;Documentation (https://docs.microsoft.com/en-us/azure/databricks/sql/language-manual/sql-ref-syntax-ddl-create-table-using#parameters) says:&lt;/P&gt;&lt;P&gt;&lt;I&gt;"When ALWAYS is used, you cannot provide your own values for the identity column." &lt;/I&gt;- so, I'm using BY DEFAULT because this allows to do that.&lt;/P&gt;&lt;P&gt;Is that suppose to work that way? I thought that identity is identity &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And another quote from docs:&lt;/P&gt;&lt;P&gt;&lt;I&gt;"When you write to the table, and do not provide values for the identity column, it will be automatically assigned a unique and statistically increasing value"&lt;/I&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Sep 2022 10:39:39 GMT</pubDate>
    <dc:creator>Leszek</dc:creator>
    <dc:date>2022-09-16T10:39:39Z</dc:date>
    <item>
      <title>IDENTITY column duplication when using BY DEFAULT parameter</title>
      <link>https://community.databricks.com/t5/data-engineering/identity-column-duplication-when-using-by-default-parameter/m-p/31567#M22999</link>
      <description>&lt;P&gt;Hi, I created delta table with identity column using this syntax:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Id BIGINT GENERATED BY DEFAULT AS IDENTITY&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My steps:&lt;/P&gt;&lt;P&gt;1) Created table with Id using syntax above.&lt;/P&gt;&lt;P&gt;2) Added two rows with Id = 1 and Id = 2 (BY DEFAULT allows to do that).&lt;/P&gt;&lt;P&gt;3) Run Insert (without specifying Id column)&lt;/P&gt;&lt;P&gt;My result:&lt;/P&gt;&lt;P&gt;I have duplicated Id's:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image.png"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1486iDFA56DAFC22DB29F/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;Documentation (https://docs.microsoft.com/en-us/azure/databricks/sql/language-manual/sql-ref-syntax-ddl-create-table-using#parameters) says:&lt;/P&gt;&lt;P&gt;&lt;I&gt;"When ALWAYS is used, you cannot provide your own values for the identity column." &lt;/I&gt;- so, I'm using BY DEFAULT because this allows to do that.&lt;/P&gt;&lt;P&gt;Is that suppose to work that way? I thought that identity is identity &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And another quote from docs:&lt;/P&gt;&lt;P&gt;&lt;I&gt;"When you write to the table, and do not provide values for the identity column, it will be automatically assigned a unique and statistically increasing value"&lt;/I&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 10:39:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/identity-column-duplication-when-using-by-default-parameter/m-p/31567#M22999</guid>
      <dc:creator>Leszek</dc:creator>
      <dc:date>2022-09-16T10:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: IDENTITY column duplication when using BY DEFAULT parameter</title>
      <link>https://community.databricks.com/t5/data-engineering/identity-column-duplication-when-using-by-default-parameter/m-p/31568#M23000</link>
      <description>&lt;P&gt;Use below alter command to sync the identity column.&lt;/P&gt;&lt;P&gt;alter table table_name change column col_name sync identity&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 10:01:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/identity-column-duplication-when-using-by-default-parameter/m-p/31568#M23000</guid>
      <dc:creator>dileep_vikram</dc:creator>
      <dc:date>2023-05-11T10:01:59Z</dc:date>
    </item>
  </channel>
</rss>

