<?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: Failed to merge incompatible data types LongType and StringType in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/failed-to-merge-incompatible-data-types-longtype-and-stringtype/m-p/19884#M13399</link>
    <description>&lt;P&gt;Hi @Tássio Santos​&amp;nbsp;&lt;/P&gt;&lt;P&gt;The delta table performs schema validation of every column, and the source dataframe column data types must match the column data types in the target table. If they don’t match, an exception is raised.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For reference-&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/delta/delta-batch.html#schema-validation-1" alt="https://docs.databricks.com/delta/delta-batch.html#schema-validation-1" target="_blank"&gt;https://docs.databricks.com/delta/delta-batch.html#schema-validation-1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can cast the column explicitly before writing it to target table to avoid this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Jun 2022 12:39:36 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-06-06T12:39:36Z</dc:date>
    <item>
      <title>Failed to merge incompatible data types LongType and StringType</title>
      <link>https://community.databricks.com/t5/data-engineering/failed-to-merge-incompatible-data-types-longtype-and-stringtype/m-p/19883#M13398</link>
      <description>&lt;P&gt;Guys, good morning!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am writing the results of a json in a delta table, only the json structure is not always the same, if the field does not list in the json it generates type incompatibility when I append&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(dfbrzagend.write&lt;/P&gt;&lt;P&gt;&amp;nbsp;.format("delta")&lt;/P&gt;&lt;P&gt;&amp;nbsp;.mode("append")&lt;/P&gt;&lt;P&gt;&amp;nbsp;.option("inferSchema", "true")&lt;/P&gt;&lt;P&gt;&amp;nbsp;.option("path",brzpath)&lt;/P&gt;&lt;P&gt;&amp;nbsp;.option("schema",defaultschema)&lt;/P&gt;&lt;P&gt;&amp;nbsp;.saveAsTable(brzbdtable))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Failed to merge fields 'age_responsavelnotafiscalpallet' and 'age_responsavelnotafiscalpallet'. Failed to merge incompatible data types LongType and StringType&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2022 13:00:35 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/failed-to-merge-incompatible-data-types-longtype-and-stringtype/m-p/19883#M13398</guid>
      <dc:creator>tassiodahora</dc:creator>
      <dc:date>2022-05-23T13:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to merge incompatible data types LongType and StringType</title>
      <link>https://community.databricks.com/t5/data-engineering/failed-to-merge-incompatible-data-types-longtype-and-stringtype/m-p/19884#M13399</link>
      <description>&lt;P&gt;Hi @Tássio Santos​&amp;nbsp;&lt;/P&gt;&lt;P&gt;The delta table performs schema validation of every column, and the source dataframe column data types must match the column data types in the target table. If they don’t match, an exception is raised.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For reference-&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/delta/delta-batch.html#schema-validation-1" alt="https://docs.databricks.com/delta/delta-batch.html#schema-validation-1" target="_blank"&gt;https://docs.databricks.com/delta/delta-batch.html#schema-validation-1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can cast the column explicitly before writing it to target table to avoid this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 12:39:36 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/failed-to-merge-incompatible-data-types-longtype-and-stringtype/m-p/19884#M13399</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-06-06T12:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to merge incompatible data types LongType and StringType</title>
      <link>https://community.databricks.com/t5/data-engineering/failed-to-merge-incompatible-data-types-longtype-and-stringtype/m-p/19886#M13401</link>
      <description>&lt;P&gt;The following example shows changing a column type:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;(spark.read.table(...)
  .withColumn("birthDate", col("birthDate").cast("date"))
  .write
  .mode("overwrite")
  .option("overwriteSchema", "true")
  .saveAsTable(...)
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Details see &lt;A href="https://docs.databricks.com/delta/update-schema.html" target="test_blank"&gt;https://docs.databricks.com/delta/update-schema.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Nov 2022 10:06:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/failed-to-merge-incompatible-data-types-longtype-and-stringtype/m-p/19886#M13401</guid>
      <dc:creator>ifun</dc:creator>
      <dc:date>2022-11-25T10:06:00Z</dc:date>
    </item>
  </channel>
</rss>

