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: 

spark.sql query is executing from the except block even though the try block is succeeded

Arun2151
New Contributor II

I have developed a azure databricks notebook where data will be copied from landing zone to STG delta table, used Try and except blocks in the code to catch the errors, if their is an error the except block will catch the error message. In the except block i have written the sql query to update the values in audit table by using spark.sql.  My issue is when try block got succeeded some how the sql query in except block is executing and updating the audit table for the error description column with the output of the  succeeded Try block . Please suggest me in this regard.

1 REPLY 1

Arun2151
New Contributor II

below is my code

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group