Hi Ravi,
Thank you for posting query in Microsoft Q&A Platform.
You can consider using
spark.sql()
to run your SQL and then usetry
andexcept
blocks. Intry
block usespark.sql()
function to run your SQL and if any exception then execution will go toexcept
block. Inexcept
consider having code which writes your error details into some table as per your requirement.For some reason, after writing error details to table, if still you want to make sure cell to fail, then write code to intentionally fail in
except
block at the end.
Below is sample code:
try:
# sql code to run
spark.sql("")
except Exception as e:
#write code here to log error details to some log table.
#below code to make cell intentionally to fail. That we can make sure cell to fail
raise Exception("Intentional failure")
Hope this helps. Please let me know if any further queries.
Please consider hitting Accept Answer
button. Accepted answers help community as well.