I have a client API in python which executes BigQuery job to trigger a query and write query result into respective BigQuery table. How to determine whether that query result returns zero records at any execution or not?
Python code:
def main(request):
query = "select * from `myproject.mydataset.mytable`"
client = bigquery.Client()
job_config = bigquery.QueryJobConfig()
dest_dataset = client.dataset(destination_dataset, destination_project)
dest_table = dest_dataset.table(destination_table)
job_config.destination = dest_table
job_config.create_disposition = 'CREATE_IF_NEEDED'
job_config.write_disposition = 'WRITE_APPEND'
job = client.query(query, location='US', job_config=job_config)
job.result()
I want If query result is having none record then it should print some message for me. Can anybody suggest how to get this done.