Skip to content

Commit

Permalink
Make creating the BigQuery job data pluggable.
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 committed Apr 30, 2019
1 parent f777a5e commit 4f1b927
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 @@ -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": {
Expand All @@ -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(),
Expand Down

0 comments on commit 4f1b927

Please sign in to comment.