Skip to content

Conversation

@BTeclaw
Copy link
Contributor

@BTeclaw BTeclaw commented Jul 31, 2024

This PR is a resolution to the given issue #39622. The main bug here was that the hook parameters were not properly given to the SnowflakeSqlAPIHook and then they were not properly assigned. The query execution method of the hook statically assigned configuration from Airflow connection. In this PR it is changed so that:

  1. hook_params from SnowflakeSqlApiOperator object is passed into the hook object through unpacking the variable.
  2. In SnowflakeSqlApiHook, for each of the parameter (database, role, schema, warehouse) there is a check performed for whether they were provided in the parameters (in their parent class SnowflakeHook, they are initialized to None, hence the if self.database|schema|role|warehouse) and if not, they are taken from connection definition.

closes: #39622


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@boring-cyborg boring-cyborg bot added area:providers provider:snowflake Issues related to Snowflake provider labels Jul 31, 2024
@boring-cyborg
Copy link

boring-cyborg bot commented Jul 31, 2024

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 Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.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

@BTeclaw BTeclaw marked this pull request as ready for review July 31, 2024 10:46
@BTeclaw BTeclaw requested review from mik-laj and potiuk as code owners July 31, 2024 10:46
@BTeclaw BTeclaw force-pushed the bugfix/fix-SnowflakeSqlApiOperator-hook-params branch from de89a29 to f4db682 Compare August 2, 2024 07:05
@potiuk
Copy link
Member

potiuk commented Aug 2, 2024

Can you please add/modify a unit test for this?

@eladkal
Copy link
Contributor

eladkal commented Aug 9, 2024

@BTeclaw reminder about adding tests

@BTeclaw BTeclaw force-pushed the bugfix/fix-SnowflakeSqlApiOperator-hook-params branch from 9c693fb to 588c520 Compare August 9, 2024 11:17
@BTeclaw
Copy link
Contributor Author

BTeclaw commented Aug 9, 2024

Pushed unit test for parametrization of the API call, haven't really written any unit tests like that before so feedback is welcome! Thanks

@BTeclaw BTeclaw force-pushed the bugfix/fix-SnowflakeSqlApiOperator-hook-params branch from 507a197 to 6fae2c3 Compare August 13, 2024 09:17
Copy link
Member

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

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

Some nitpicks, but overall looks good

BTeclaw and others added 2 commits August 15, 2024 12:46
Co-authored-by: Wei Lee <weilee.rx@gmail.com>
Co-authored-by: Wei Lee <weilee.rx@gmail.com>
@BTeclaw
Copy link
Contributor Author

BTeclaw commented Aug 15, 2024

@Lee-W applied suggested changes - thank you!

@Lee-W Lee-W merged commit 5790cf7 into apache:main Aug 15, 2024
@boring-cyborg
Copy link

boring-cyborg bot commented Aug 15, 2024

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

Artuz37 pushed a commit to Artuz37/airflow that referenced this pull request Aug 19, 2024
…I call (apache#41150)

---------

Co-authored-by: Blazej Teclaw <blazej.teclaw@hlag.com>
Co-authored-by: Wei Lee <weilee.rx@gmail.com>
romsharon98 pushed a commit to romsharon98/airflow that referenced this pull request Aug 20, 2024
…I call (apache#41150)

---------

Co-authored-by: Blazej Teclaw <blazej.teclaw@hlag.com>
Co-authored-by: Wei Lee <weilee.rx@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:snowflake Issues related to Snowflake provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DB Parameters not passed through to Snowflake API Connection

4 participants