cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

hi all - I have created a data frame and would like to save in delta format using df.write.format("delta").saveAsTable("tablename") Its not working and throws " AnalysisException" . Please advise .

joakon
New Contributor III
 
1 ACCEPTED SOLUTION

Accepted Solutions

Anonymous
Not applicable

Your code is not wrong, I tried and executed from my side and no error happens.

Could you check version of DBR?

Image

View solution in original post

6 REPLIES 6

Pat
Honored Contributor III

Hi @raghu maremandaโ€‹ ,

can you please share error details?

are you using PYTHON CELL to execute the code?

I am not sure right now if it's optional or mandatory, but you could add .mode() i.e:

df.write.format("delta").mode("append").saveAsTable("tablename")
 
append or overwrite

please refer to: https://docs.delta.io/latest/delta-batch.html#write-to-a-table

joakon
New Contributor III

Thank you for your response.

This is what I have so far -

d = spark.read.option("inferSchema" ,"true").option("delimeter" ,",").option("header","true").csv('dbfs:/FileStore/tables/Devices.csv')

d.write.format("delta").mode("append").saveAsTable("devices_new")

image.png

Pat
Honored Contributor III

@raghu maremandaโ€‹ ,

you didn't add the .mode() in your code shown.

it's still:

d.write.format("delta").saveAsTable("delta.devices_new")

I am not sure if this will help, but try:

d.write.format("delta").mode("append").saveAsTable("devices_new")

also, the error doesn't tell much. can you share the error thrown?

thanks,

Pat.

Anonymous
Not applicable

Your code is not wrong, I tried and executed from my side and no error happens.

Could you check version of DBR?

Image

joakon
New Contributor III

thank you for the response. db runtime was older. issue resolved.

huyd
New Contributor III

check your read cell, "Delimeter"

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group