Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding configurable BigQuery ProjectID on contrib jobs #3019

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions luigi/contrib/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,12 @@ def allow_quoted_new_lines(self):
""" Indicates if BigQuery should allow quoted data sections that contain newline characters in a CSV file. The default value is false."""
return False

@property
def project_id(self):
"""Project ID on which to run the BigQuery Job
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add short description for the default value as well?

"""
return self.output().table.project_id

def run(self):
output = self.output()
assert isinstance(output, BigQueryTarget), 'Output must be a BigQueryTarget, not %s' % (output)
Expand Down Expand Up @@ -565,7 +571,7 @@ def run(self):
else:
job['configuration']['load']['autodetect'] = True

bq_client.run_job(output.table.project_id, job, dataset=output.table.dataset)
bq_client.run_job(self.project_id, job, dataset=output.table.dataset)


class BigQueryRunQueryTask(MixinBigQueryBulkComplete, luigi.Task):
Expand Down Expand Up @@ -610,6 +616,12 @@ def use_legacy_sql(self):
"""
return True

@property
def project_id(self):
"""Project ID on which to run the BigQuery Job
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

"""
return self.output().table.project_id

def run(self):
output = self.output()
assert isinstance(output, BigQueryTarget), 'Output must be a BigQueryTarget, not %s' % (output)
Expand Down Expand Up @@ -643,7 +655,7 @@ def run(self):
}
}

bq_client.run_job(output.table.project_id, job, dataset=output.table.dataset)
bq_client.run_job(self.project_id, job, dataset=output.table.dataset)


class BigQueryCreateViewTask(luigi.Task):
Expand Down