Skip to content

Commit

Permalink
bigquery: Disable cache when dumping
Browse files Browse the repository at this point in the history
Disable query caching when dumping data from BigQuery in an attempt to
fix the database purging test (test_purge_db()).

Revert if there's no effect on test stability.
  • Loading branch information
spbnick committed Nov 20, 2024
1 parent 8a70a15 commit e83de41
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions kcidb/db/bigquery/v04_00.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def __init__(self, params):
except GoogleNotFound as exc:
raise NotFound(params) from exc

def query_create(self, query_string, query_parameters=None):
def query_create(self, query_string, query_parameters=None,
use_query_cache=True):
"""
Creates a Query job configured for a given query string and
optional parameters. BigQuery can run the job to query the database.
Expand All @@ -89,6 +90,8 @@ def query_create(self, query_string, query_parameters=None):
query_parameters: A list containing the optional query parameters
(google.cloud.bigquery.ArrayQueryParameter).
The default is an empty list.
use_query_cache: True if BigQuery query cache should be used,
False otherwise.
Returns:
The Query job (google.cloud.bigquery.job.QueryJob)
Expand All @@ -97,7 +100,10 @@ def query_create(self, query_string, query_parameters=None):
query_parameters = []
LOGGER.debug("Query string: %s", query_string)
LOGGER.debug("Query params: %s", query_parameters)
if not use_query_cache:
LOGGER.debug("Query cache: DISABLED")
job_config = bigquery.job.QueryJobConfig(
use_query_cache=use_query_cache,
query_parameters=query_parameters,
default_dataset=self.dataset_ref)
return self.client.query(query_string, job_config=job_config)
Expand Down Expand Up @@ -806,7 +812,8 @@ def dump_iter(self, objects_per_report, with_metadata, after, until):
bigquery.ScalarQueryParameter(None, ts_field.field_type, v)
for v in (table_after, table_until) if v
]
query_job = self.conn.query_create(query_string, query_parameters)
query_job = self.conn.query_create(query_string, query_parameters,
use_query_cache=False)
obj_list = None
for row in query_job:
if obj_list is None:
Expand Down

0 comments on commit e83de41

Please sign in to comment.