From 4f1b9277555e7010d7f32665a10ad72344ce8f92 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 29 Apr 2019 11:58:43 +0200 Subject: [PATCH] Make creating the BigQuery job data pluggable. This would for example allow adding custom job labels (https://cloud.google.com/bigquery/docs/adding-using-labels#job-label) for easier accounting. --- redash/query_runner/big_query.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/redash/query_runner/big_query.py b/redash/query_runner/big_query.py index 3a9ecb81e5..25f3193660 100644 --- a/redash/query_runner/big_query.py +++ b/redash/query_runner/big_query.py @@ -176,8 +176,7 @@ def _get_total_bytes_processed(self, jobs, query): response = jobs.query(projectId=self._get_project_id(), body=job_data).execute() return int(response["totalBytesProcessed"]) - def _get_query_result(self, jobs, query): - project_id = self._get_project_id() + def _get_job_data(self, query): job_data = { "configuration": { "query": { @@ -202,6 +201,11 @@ def _get_query_result(self, jobs, query): if "maximumBillingTier" in self.configuration: job_data["configuration"]["query"]["maximumBillingTier"] = self.configuration["maximumBillingTier"] + return job_data + + def _get_query_result(self, jobs, query): + project_id = self._get_project_id() + job_data = self._get_job_data() insert_response = jobs.insert(projectId=project_id, body=job_data).execute() current_row = 0 query_reply = _get_query_results(jobs, project_id=project_id, location=self._get_location(),