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

Add Snowflake support to SQL operator and sensor #9843

Merged
merged 3 commits into from
Jul 17, 2020

Conversation

liuandy
Copy link
Contributor

@liuandy liuandy commented Jul 15, 2020

Add Snowflake as supported database backend for SQL operator and sensor. This is primarily an update to the allowed_conn_type sets for the corresponding classes.

Closes #9548

Make sure to mark the boxes below before creating PR: [x]

  • Description above provides context of the change
  • Unit tests coverage for changes (not needed for documentation changes)
  • Target Github ISSUE in description if exists
  • Commits follow "How to write a good git commit message"
  • Relevant documentation is updated including usage instructions.
  • I will engage committers as explained in Contribution Workflow Example.

In case of fundamental code change, 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 UPDATING.md.
Read the Pull Request Guidelines for more information.

@boring-cyborg
Copy link

boring-cyborg bot commented Jul 15, 2020

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/master/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (flake8, pylint 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.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://apache-airflow-slack.herokuapp.com/

@@ -80,6 +80,7 @@
"postgres": ("airflow.providers.postgres.hooks.postgres.PostgresHook", "postgres_conn_id"),
"presto": ("airflow.providers.presto.hooks.presto.PrestoHook", "presto_conn_id"),
"redis": ("airflow.providers.redis.hooks.redis.RedisHook", "redis_conn_id"),
"snowflake": ("airflow.providers.snowflake.hooks.snowflake.SnowflakeHook", "snowflake_conn_id"),
Copy link
Member

@turbaszek turbaszek Jul 15, 2020

Choose a reason for hiding this comment

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

Would you mind adding a simple test to check that all hooks' path are valid? For example using importlib? We can try to use airflow.utils.module_loading.import_string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@turbaszek Added, but requires updating the MSSQL mapping to ODBC per deprecation notice. Since pymssql is deprecated, the existing hook throws an import error for the existing MSSQL mapping.

Copy link
Member

Choose a reason for hiding this comment

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

Good! In this way, you've found a bug 👌

Comment on lines 539 to 540
for conn_type in CONN_TYPE_TO_HOOK:
self.assertTrue(issubclass(import_string(CONN_TYPE_TO_HOOK[conn_type][0]), BaseHook))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for conn_type in CONN_TYPE_TO_HOOK:
self.assertTrue(issubclass(import_string(CONN_TYPE_TO_HOOK[conn_type][0]), BaseHook))
for hook_path, _ in CONN_TYPE_TO_HOOK.values():
self.assertTrue(issubclass(import_string(hook_path), BaseHook))

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LGTM. This is much cleaner.

@turbaszek turbaszek merged commit 9c68e7c into apache:master Jul 17, 2020
@boring-cyborg
Copy link

boring-cyborg bot commented Jul 17, 2020

Awesome work, congrats on your first merged pull request!

scrambldchannel pushed a commit to scrambldchannel/airflow that referenced this pull request Jul 17, 2020
* Add Snowflake support to SQL operator and sensor
* Add test for conn_type to valid hook mapping
* Improve code quality for conn type mapping test
@eladkal
Copy link
Contributor

eladkal commented Jul 20, 2020

@kaxil @potiuk can it be cheery picked to 1.10.12 ? 🙏

@potiuk potiuk added this to the Airflow 1.10.12 milestone Jul 20, 2020
@potiuk
Copy link
Member

potiuk commented Jul 20, 2020

Marked for inclusion to 1.10.12. Should be easy to cherry-pick

kaxil pushed a commit that referenced this pull request Aug 12, 2020
* Add Snowflake support to SQL operator and sensor
* Add test for conn_type to valid hook mapping
* Improve code quality for conn type mapping test

(cherry picked from commit 9c68e7c)
kaxil pushed a commit that referenced this pull request Aug 15, 2020
* Add Snowflake support to SQL operator and sensor
* Add test for conn_type to valid hook mapping
* Improve code quality for conn type mapping test

(cherry picked from commit 9c68e7c)
cfei18 pushed a commit to cfei18/incubator-airflow that referenced this pull request Mar 5, 2021
* Add Snowflake support to SQL operator and sensor
* Add test for conn_type to valid hook mapping
* Improve code quality for conn type mapping test

(cherry picked from commit 9c68e7c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for snowflake on the sql_sensor
4 participants