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:ย 

Does Delta refresh DF cache automatically after a delete?

MoJaMa
Databricks Employee
Databricks Employee
 
2 REPLIES 2

MoJaMa
Databricks Employee
Databricks Employee

Yes. Delta actually explicitly refreshes the dataframe cache after performing delete.

Use this code to test it out.

Seq((0,"A"), (1,"B"),(2,"C")  ).toDF("id","value").write.format("delta").mode("overwrite").saveAsTable("target_tbl") 
 
val df = spark.sql("select * from target_tbl")
df.persist()
df.show()
 
spark.sql("delete from target_tbl where id = 2")
df.show()
df.unpersist()
 
Output:
+---+-----+
| id|value|
+---+-----+
|  0|    A|
|  2|    C|
|  1|    B|
+---+-----+
+---+-----+
| id|value|
+---+-----+
|  0|    A|
|  1|    B|
+---+-----+

Srikanth_Gupta_
Valued Contributor

How about updates and inserts? does it refresh automatically?

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