Skip to content

Commit

Permalink
Make creating the BigQuery job data pluggable. (#3742)
Browse files Browse the repository at this point in the history
This would for example allow adding custom job labels (https://cloud.google.com/bigquery/docs/adding-using-labels#job-label) for easier accounting.
  • Loading branch information
jezdez authored and arikfr committed Apr 29, 2019
1 parent c93a905 commit 99bb24d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions redash/query_runner/big_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,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": {
Expand All @@ -198,6 +197,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(),
Expand Down

0 comments on commit 99bb24d

Please sign in to comment.