How can we import the exception "MetadataChangedException"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 03:14 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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

