Reputation:
I'm using the BigQuery API to run a query with the following code:
query = (
'SELEC ...'
)
# API request - starts the query
query_job = client.query(
query,
location='US'
)
results = query_job.result()
The query works and outputs expected results. However, I am not able to verify use of the cache.
Docs:
If you are using the BigQuery API, the
cacheHit
property in the query result is set to true.
I am trying to access results.cacheHit, but it does work out.
AttributeError: 'RowIterator' object has no attribute 'cacheHit'
What am I doing wrong? How can I see the use of cache with my query?
Upvotes: 0
Views: 482
Reputation: 1672
The quote you are using from docs refers to the REST API (cacheHit is in the response of the getQueryResults method).
What you need instead is query_job.cache_hit
Upvotes: 1