<?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: Identity column definition lost using save as table in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/identity-column-definition-lost-using-save-as-table/m-p/21188#M14406</link>
    <description>&lt;P&gt;try to avoid reload table, I found we can upgrade table version, and use rename column command&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ALTER TABLE test_id2 SET TBLPROPERTIES (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;'delta.columnMapping.mode' = 'name',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;'delta.minReaderVersion' = '2',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;'delta.minWriterVersion' = '6')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ALTER TABLE test_id2 rename column a to a1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the last issue looks like no way to avoid recreating the table if we need change the partition. change partition will require a reset identity column, GENERATED ALWAYS option, which is not ideal if the column is a key for a dimension and is being referenced by other tables.&lt;/P&gt;</description>
    <pubDate>Thu, 10 Nov 2022 14:47:19 GMT</pubDate>
    <dc:creator>lizou</dc:creator>
    <dc:date>2022-11-10T14:47:19Z</dc:date>
    <item>
      <title>Identity column definition lost using save as table</title>
      <link>https://community.databricks.com/t5/data-engineering/identity-column-definition-lost-using-save-as-table/m-p/21184#M14402</link>
      <description>&lt;P&gt;I found an issue:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For a table with an identity column defined.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when the table column is renamed using this method, the identity definition will be removed. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That means using an identity column in a table requires extra attention to check whether the identity column is still there, and the current seed value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;code example&lt;/P&gt;&lt;P&gt;spark.read.table(...) \&lt;/P&gt;&lt;P&gt;  .withColumnRenamed("dateOfBirth", "birthDate") \&lt;/P&gt;&lt;P&gt;  .write \&lt;/P&gt;&lt;P&gt;  .format("delta") \&lt;/P&gt;&lt;P&gt;  .mode("overwrite") \&lt;/P&gt;&lt;P&gt;  .option("overwriteSchema", "true") \&lt;/P&gt;&lt;P&gt;  .saveAsTable(...)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/delta/delta-batch.html#explicit-schema-update" target="test_blank"&gt;https://docs.databricks.com/delta/delta-batch.html#explicit-schema-update&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;example of a table with an identity column&lt;/P&gt;&lt;P&gt;CREATE TABLE table_with_identity_col (&lt;/P&gt;&lt;P&gt;  RowKey bigint not null GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1) comment 'identity',&lt;/P&gt;&lt;P&gt;  UserName string&lt;/P&gt;&lt;P&gt;)  USING DELTA;&lt;/P&gt;</description>
      <pubDate>Sun, 08 May 2022 15:41:24 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/identity-column-definition-lost-using-save-as-table/m-p/21184#M14402</guid>
      <dc:creator>lizou</dc:creator>
      <dc:date>2022-05-08T15:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: Identity column definition lost using save as table</title>
      <link>https://community.databricks.com/t5/data-engineering/identity-column-definition-lost-using-save-as-table/m-p/21185#M14403</link>
      <description>&lt;P&gt;@lizou​&amp;nbsp;, Identity id is stored in schema and using overwriteSchema will for sure kill it ;-(&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2022 06:54:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/identity-column-definition-lost-using-save-as-table/m-p/21185#M14403</guid>
      <dc:creator>Hubert-Dudek</dc:creator>
      <dc:date>2022-05-09T06:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: Identity column definition lost using save as table</title>
      <link>https://community.databricks.com/t5/data-engineering/identity-column-definition-lost-using-save-as-table/m-p/21187#M14405</link>
      <description>&lt;P&gt;Hey there @lizou​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We'd love to hear from you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 17:22:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/identity-column-definition-lost-using-save-as-table/m-p/21187#M14405</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-06-20T17:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Identity column definition lost using save as table</title>
      <link>https://community.databricks.com/t5/data-engineering/identity-column-definition-lost-using-save-as-table/m-p/21188#M14406</link>
      <description>&lt;P&gt;try to avoid reload table, I found we can upgrade table version, and use rename column command&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ALTER TABLE test_id2 SET TBLPROPERTIES (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;'delta.columnMapping.mode' = 'name',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;'delta.minReaderVersion' = '2',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;'delta.minWriterVersion' = '6')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ALTER TABLE test_id2 rename column a to a1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the last issue looks like no way to avoid recreating the table if we need change the partition. change partition will require a reset identity column, GENERATED ALWAYS option, which is not ideal if the column is a key for a dimension and is being referenced by other tables.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 14:47:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/identity-column-definition-lost-using-save-as-table/m-p/21188#M14406</guid>
      <dc:creator>lizou</dc:creator>
      <dc:date>2022-11-10T14:47:19Z</dc:date>
    </item>
  </channel>
</rss>

