0

I am calling BQ Stored proc via Cloud function and have below try catch block

try:

    sql = """CALL `utl.##`(NULL, 1, 3);"""
    job = client.query(sql)
    job.result()
    print("job executed for query:{}".format(sql))
except Exception as e:
    print("error message:  "+job.error_result['message'])
    print(job.exception())

Stored Proc job status is success but one of the statement failed and throw some exception . I would like to capture that in Cloud function. Is there any way?

Mudgal
  • 35
  • 4
  • Check out this similar question: https://stackoverflow.com/questions/57039771/how-to-get-detailed-big-query-error-by-using-python – Daniel Zagales Sep 23 '22 at 10:22

1 Answers1

0

Solved !! I was able to capture all errors in CF with the change in BQ stored Proc. By properly raising exception message.

EXCEPTION WHEN ERROR THEN
select @@error.message
with 
 EXCEPTION WHEN ERROR THEN  
    RAISE USING MESSAGE = @@error.message ;
Mudgal
  • 35
  • 4