Failed to merge incompatible data types LongType and StringType

tassiodahora
New Contributor III

Guys, good morning!

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

(dfbrzagend.write

 .format("delta")

 .mode("append")

 .option("inferSchema", "true")

 .option("path",brzpath)

 .option("schema",defaultschema)

 .saveAsTable(brzbdtable))

Failed to merge fields 'age_responsavelnotafiscalpallet' and 'age_responsavelnotafiscalpallet'. Failed to merge incompatible data types LongType and StringType