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

fix(bigquery.py): pass correct project_id to triggerer #35200

Merged
merged 16 commits into from
Dec 17, 2023

Conversation

mokshasoul
Copy link
Contributor

The triggerer uses a different project than the InsertJobOperator when the project_id passed to the operator = None

The triggerer uses a different project than the InsertJobOperator when the `project_id` passed to the operator = None
@boring-cyborg boring-cyborg bot added area:providers provider:google Google (including GCP) related issues labels Oct 26, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Oct 26, 2023

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

Copy link
Member

@hussein-awala hussein-awala left a comment

Choose a reason for hiding this comment

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

Could you add a unit test for this change?

Comment on lines +2791 to +2792
if self.project_id is None:
self.project_id = hook.project_id
Copy link
Member

Choose a reason for hiding this comment

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

to be consistent with L2852, although either is fine

Suggested change
if self.project_id is None:
self.project_id = hook.project_id
self.project_id = self.project_id or self.hook.project_id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would remove all references that do project_id = self.project_id or self.hook.project_id since this is what caused the whole issue in the first place, IMO.

The style I'm following is the one used for most hooks assignments when mutating the object on execution

@mokshasoul
Copy link
Contributor Author

Could you add a unit test for this change?

I wanted to do this but unfortunately the dev-containers don't work on apple-silicon macs.

I have added the test and will push and test this on an intel mac later this week.

We've also forwarded this too Google since this is causing major issues for us

@mokshasoul mokshasoul marked this pull request as draft November 15, 2023 09:33
@mokshasoul mokshasoul marked this pull request as ready for review November 15, 2023 09:34
@mokshasoul
Copy link
Contributor Author

bump

@eladkal
Copy link
Contributor

eladkal commented Nov 24, 2023

Tests are failing

FAILED tests/providers/google/cloud/operators/test_bigquery.py::TestBigQueryInsertJobOperator::test_bigquery_insert_job_operator_async_inherits_hook_project_id_when_non_given - AssertionError: assert equals failed
  <MagicMock name='BigQueryHook()  'test-project'                  
  .project_id' id='14059973921963                                  
  2'>

@mokshasoul
Copy link
Contributor Author

@eladkal can you retrigger the tests? I managed to run and verify everything on my local machine

@mokshasoul
Copy link
Contributor Author

So there's another test failing but thats not part of the code I touched I guess that is fine?

@mokshasoul
Copy link
Contributor Author

Good morning folx, thx for your patience.

Does this look good now? I fixed the last few issues I was seeing from the static-checks as well

Copy link
Member

@hussein-awala hussein-awala left a comment

Choose a reason for hiding this comment

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

It looks good, LGTM

@potiuk potiuk merged commit ffb003a into apache:main Dec 17, 2023
50 checks passed
Copy link

boring-cyborg bot commented Dec 17, 2023

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers provider:google Google (including GCP) related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants