cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Does Delta refresh DF cache automatically after a delete?

MoJaMa
Valued Contributor II
Valued Contributor II
 
2 REPLIES 2

MoJaMa
Valued Contributor II
Valued Contributor II

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?

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.