I am trying to catch any error, when I ran query in Bigquery through Python Operator in airflow. But I am not able to get the expected behaviour. Its not throwing any exception.
This is what I have tried.
from google.cloud import bigquery
client = bigquery.Client(project='project_id')
query = "select 1 as cnt from gudb.TEST001 limit 1"
try:
client.query(query)
except Exception as e:
print(e)
its not throwing any exception, even the table is not available in bigquery. But when I tried to store the variable
var=client.query(query) # in try
for x in var:
print(x)
I can see the exception stored in that var. But I am expecting to get the exception to be prompted in the stdout when I try to run the try except block.
Can someone please let me know, how to get the exception