<?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 to add an identity column to an existing table? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31968#M23308</link>
    <description>&lt;P&gt;My DBR &lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1520i9ADC51A5E707E5A0/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Sep 2022 23:46:17 GMT</pubDate>
    <dc:creator>PriyaAnanthram</dc:creator>
    <dc:date>2022-09-14T23:46:17Z</dc:date>
    <item>
      <title>how to add an identity column to an existing table?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31959#M23299</link>
      <description>&lt;P&gt;I have created a database called retail and inside database a table is there called sales_order. I want to create an identity column in the sales_order table, but while creating it I am getting an error. &lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 07:21:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31959#M23299</guid>
      <dc:creator>ramankr48</dc:creator>
      <dc:date>2022-09-13T07:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to add an identity column to an existing table?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31960#M23300</link>
      <description>&lt;P&gt;That is because you can't add an id column to an existing table.&lt;/P&gt;&lt;P&gt;Instead create a table from scratch and copy data:&lt;/P&gt;&lt;P&gt;CREATE TABLE tname_ (&lt;/P&gt;&lt;P&gt;    &amp;lt;tname columns&amp;gt;,&lt;/P&gt;&lt;P&gt;    id BIGINT GENERATED BY DEFAULT AS IDENTITY&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;INSERT INTO tname_ (&amp;lt;tname columns&amp;gt;) SELECT * FROM tname;&lt;/P&gt;&lt;P&gt;DROP TABLE tname;&lt;/P&gt;&lt;P&gt;ALTER TABLE tname_ RENAME TO tname;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 08:57:24 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31960#M23300</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2022-09-13T08:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to add an identity column to an existing table?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31961#M23301</link>
      <description>&lt;P&gt;while creating a new table I'm getting an error like this: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Error in SQL statement: AnalysisException: Cannot create table ('`spark_catalog`.`retaildb`.`sales_order1`'). The associated location ('dbfs:/user/hive/warehouse/retaildb.db/sales_order1') is not empty but it's not a Delta table&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 11:29:23 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31961#M23301</guid>
      <dc:creator>ramankr48</dc:creator>
      <dc:date>2022-09-13T11:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to add an identity column to an existing table?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31962#M23302</link>
      <description>&lt;P&gt;what databricks version do you use?&lt;/P&gt;&lt;P&gt;Only as from a certain version on, delta is the default format. So if you use an older release you should add 'using delta' (and I doubt in that case if the ID column will work)&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 11:41:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31962#M23302</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2022-09-13T11:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to add an identity column to an existing table?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31963#M23303</link>
      <description>&lt;P&gt;I'm using community version&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 11:44:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31963#M23303</guid>
      <dc:creator>ramankr48</dc:creator>
      <dc:date>2022-09-13T11:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to add an identity column to an existing table?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31964#M23304</link>
      <description>&lt;P&gt;It is possible that it is not supported with the CE.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 11:54:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31964#M23304</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2022-09-13T11:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to add an identity column to an existing table?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31965#M23305</link>
      <description>&lt;P&gt;Can you please tell me  why it is showing job aborted ? same identity column issue.&lt;/P&gt;&lt;P&gt;I'm able to create table but while inserting the data it's saying : &lt;/P&gt;&lt;P&gt;Error in SQL statement: SparkException: Job aborted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;error file is attached named: blocker5&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/1511i804862E914D05284/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 07:46:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31965#M23305</guid>
      <dc:creator>ramankr48</dc:creator>
      <dc:date>2022-09-14T07:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to add an identity column to an existing table?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31966#M23306</link>
      <description>&lt;P&gt;above error is from community version.&lt;/P&gt;&lt;P&gt;and in azure version also it is showing the error.&lt;/P&gt;&lt;P&gt;i.e : &lt;/P&gt;&lt;P&gt;org.apache.spark.SparkException: Job aborted.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 09:03:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31966#M23306</guid>
      <dc:creator>ramankr48</dc:creator>
      <dc:date>2022-09-14T09:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to add an identity column to an existing table?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31967#M23307</link>
      <description>&lt;P&gt;I just did this on the community cluster&lt;/P&gt;&lt;P&gt;%sql&lt;/P&gt;&lt;P&gt;create or replace table picklist&lt;/P&gt;&lt;P&gt;( picklist_id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;BIGINT not null GENERATED ALWAYS AS IDENTITY(start with 1 increment by 1),&lt;/P&gt;&lt;P&gt;&amp;nbsp;picklist_Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string&amp;nbsp;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;insert into picklist(picklist_Name) values('a');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;insert into picklist(picklist_Name) values('b');&lt;/P&gt;&lt;P&gt;insert into picklist(picklist_Name) values('c');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from picklist&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1510i6D1690458595412B/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;Also check DESCRIBE to see where the delta table is saved&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/1513i500D79D542D82052/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;I have a feeling its the version of the DBR that your using &lt;/P&gt;&lt;P&gt;Could you use the latest and see if that helps you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 22:58:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31967#M23307</guid>
      <dc:creator>PriyaAnanthram</dc:creator>
      <dc:date>2022-09-14T22:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to add an identity column to an existing table?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31968#M23308</link>
      <description>&lt;P&gt;My DBR &lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1520i9ADC51A5E707E5A0/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 23:46:17 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31968#M23308</guid>
      <dc:creator>PriyaAnanthram</dc:creator>
      <dc:date>2022-09-14T23:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to add an identity column to an existing table?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31969#M23309</link>
      <description>&lt;P&gt;Thanks @Priya Ananthram​&amp;nbsp;, issue got solved&lt;/P&gt;&lt;P&gt;I used the same DBR &lt;/P&gt;&lt;P&gt;my job aborted issue got solved by using "try_cast" function while inserting the data from one table to the delta table. I used try_cast function for every column I was inserting.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 06:44:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31969#M23309</guid>
      <dc:creator>ramankr48</dc:creator>
      <dc:date>2022-09-15T06:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to add an identity column to an existing table?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31970#M23310</link>
      <description>&lt;P&gt;@Raman Gupta​&amp;nbsp; - For the error mentioned &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Error in SQL statement: AnalysisException: Cannot create table ('`spark_catalog`.`retaildb`.`sales_order1`'). The associated location ('dbfs:/user/hive/warehouse/retaildb.db/sales_order1') is not empty but it's not a Delta table&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;could you please manually clean up the data directory specified in the error message? using the below command and then try to create a table.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%scala 
dbutils.fs.rm("&amp;lt;path-to-directory&amp;gt;", true)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 21:46:28 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-add-an-identity-column-to-an-existing-table/m-p/31970#M23310</guid>
      <dc:creator>shan_chandra</dc:creator>
      <dc:date>2022-09-23T21:46:28Z</dc:date>
    </item>
  </channel>
</rss>

