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: 

How to set retention period for a delta table lower than the default period? Is it even possible?

manasa
Contributor

I am trying to set retention period for a delta by using following commands.

deltaTable = DeltaTable.forPath(spark,delta_path)

spark.conf.set("spark.databricks.delta.retentionDurationCheck.enabled", "false")

deltaTable.logRetentionDuration = "interval 1 days"

deltaTable.deletedFileRetentionDuration = "interval 1 days"

These commands are not working for me, I mean, they aren't removing any files for the given interval..where am I going wrong?

1 ACCEPTED SOLUTION

Accepted Solutions

Hubert-Dudek
Esteemed Contributor III

There are two ways:

1) Please set in cluster (Clusters -> edit -> Spark -> Spark config):

spark.databricks.delta.retentionDurationCheck.enabled false

imagen.png 

2) or just before DeltaTable.forPath set (I think you need to change order in your code):

spark.conf.set("spark.databricks.delta.retentionDurationCheck.enabled", "false")

View solution in original post

5 REPLIES 5

Hubert-Dudek
Esteemed Contributor III

There are two ways:

1) Please set in cluster (Clusters -> edit -> Spark -> Spark config):

spark.databricks.delta.retentionDurationCheck.enabled false

imagen.png 

2) or just before DeltaTable.forPath set (I think you need to change order in your code):

spark.conf.set("spark.databricks.delta.retentionDurationCheck.enabled", "false")

Hi @Manasa Kalluri​ , It seems @Hubert Dudek​ has given a comprehensive solution. Were you able to solve your problem?

Hi @Kaniz Fatma​ , Yes I was able to solve the issue! Thanks

Hi @Hubert Dudek​ , thanks for you response!

Kaniz
Community Manager
Community Manager

Hi @Manasa Kalluri​ , Thank you for the update. Would you like to mark @Hubert Dudek​ 's answer as "Best" which would help our community members hereafter 😊 ?

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!