Py4JJavaError when trying to write dataframe to delta table

AK98
New Contributor II

I'm trying to write a dataframe to a delta table and am getting this error.

image.pngIm not sure what the issue is as I had no problem successfully writing other dataframes to delta tables. I attached a snippet of the data as well along with the schema:

imageimage

Rishabh-Pandey
Databricks MVP

hey @Ashad Khan​ refer this link https://bigdataprogrammers.com/write-dataframe-to-delta-table-in-databricks-with-overwrite-mode/

that might help you ,

Rishabh Pandey

ramravi
Contributor II

Does your delta tables contains all columns what your dataframe contains. If there is schema mismatch it might be a reason for failure.

df.write.format("delta") \
           .option("mergeSchema", "true") \
           .mode("append") \
           .save(DELTALAKE_SILVER_PATH)

AK98
New Contributor II

My understanding was that I was writing to a brand new delta table that doesn't exist, and hence there would be no schema mismatch. I also tried the inferSchema option. Is that not the case? I did the same for other dataframes and it wasn't an issue