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 can we import the exception "MetadataChangedException"?

jkb7
New Contributor III

I regularly get
MetadataChangedException: [DELTA_METADATA_CHANGED] MetadataChangedException: The metadata of the Delta table has been changed by a concurrent update. Please try the operation again.

What is the recommended way to import this specific type of exception and handle it properly within a try-except clause?

1 REPLY 1

Nik_Vanderhoof
Contributor

Hi! It depends on whether you're using Scala or Python.

If you're using Scala, you should be able to import `io.delta.exceptions.MetadataChangedException`, which you can see defined here: https://github.com/delta-io/delta/blob/master/spark/src/main/scala/io/delta/exceptions/DeltaConcurre...

And for PySpark, I believe you might be able to catch `delta.exceptions.MetadataChangedException`, which is defined here: https://github.com/delta-io/delta/blob/master/python/delta/exceptions.py#L54 

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