cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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

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.