<?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 Overwrite Using pyspark's JDBC without loosing constraints on table columns in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-overwrite-using-pyspark-s-jdbc-without-loosing/m-p/24003#M16647</link>
    <description>&lt;P&gt;@Abeeya .​&amp;nbsp;, Mode "truncate", is correct to preserve the table. However, when you want to add a new column (mismatched schema), it wants to drop it anyway.&lt;/P&gt;</description>
    <pubDate>Fri, 01 Apr 2022 12:06:23 GMT</pubDate>
    <dc:creator>Hubert-Dudek</dc:creator>
    <dc:date>2022-04-01T12:06:23Z</dc:date>
    <item>
      <title>How to Overwrite Using pyspark's JDBC without loosing constraints on table columns</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-overwrite-using-pyspark-s-jdbc-without-loosing/m-p/24002#M16646</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My table has primary key constraint on a perticular column, Im loosing primary key constaint on that column each time I overwrite the table , What Can I do to preserve it? Any Heads up would be appreciated&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tried Below&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;df.write.option("truncate", "true").jdbc(url=DATABASE_URL, table=DATABASE_TABLE, mode="overwrite", properties=DATABASE_PROPERTIES)
&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But It errored out as below when a new column was added to dataframe which was not there in table&lt;/P&gt;&lt;P&gt;&lt;B&gt;AnalysisException: Column "new_col" not found in schema Some&lt;/B&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 11:57:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-overwrite-using-pyspark-s-jdbc-without-loosing/m-p/24002#M16646</guid>
      <dc:creator>Abeeya</dc:creator>
      <dc:date>2022-04-01T11:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to Overwrite Using pyspark's JDBC without loosing constraints on table columns</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-overwrite-using-pyspark-s-jdbc-without-loosing/m-p/24003#M16647</link>
      <description>&lt;P&gt;@Abeeya .​&amp;nbsp;, Mode "truncate", is correct to preserve the table. However, when you want to add a new column (mismatched schema), it wants to drop it anyway.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 12:06:23 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-overwrite-using-pyspark-s-jdbc-without-loosing/m-p/24003#M16647</guid>
      <dc:creator>Hubert-Dudek</dc:creator>
      <dc:date>2022-04-01T12:06:23Z</dc:date>
    </item>
  </channel>
</rss>

