Search code examples
google-bigquerygoogle-apis-explorer

Bigquery API for get the job information


support team,

I am using google bigquery API python lib to test some operations. One purpose is to get the job information. Then we can better control all our queries from the API. I found there is a get() method mentioned in the REST reference here, which can get the job information. But in the API python lib here, I can not find any doc about this get() method or something can finish the same operation.

Can you help to provide me any guide doc about any method in the python lib can get the job information?

Thanks Zhihong


Solution

  • Based on Elliott's suggestion, I got the job info I need after run a query, but not figure out how to fetch the job info for an exist job, which I think not needed anymore if got query info after each operation. The python code is as below:

    from google.cloud import bigquery
    client = bigquery.Client()
    query = client.run_sunc_query(sql)
    query.use_legacy_sql = False
    query.use_query_cache = True
    query.run()
    trows = query.total_rows
    billed_byte = query.total_bytes_processed
    

    More query info parameters can be found here and more example code can be found here.