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_
Databricks Employee
Databricks Employee

How about updates and inserts? does it refresh automatically?

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local communityโ€”sign up today to get started!

Sign Up Now