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

Change kwargs in Snowflake URI generation #84

Merged
merged 18 commits into from
Jan 10, 2023

Conversation

TJaniF
Copy link
Contributor

@TJaniF TJaniF commented Jan 6, 2023

Fixes #83 .
Snowflake provider 4.0.0 changed the kwargs generated when the connection is defined in the Airflow UI. I left the old kwargs as a fallback.

Comment on lines 246 to 248
try: # auto generated connection kwargs Snowflake provider >=4.0.0
uri_string = f"snowflake://{self.conn.login}:{self.conn.password}@{self.conn.extra_dejson['account']}.{self.conn.extra_dejson['region']}/{self.conn.extra_dejson['database']}/{schema}?warehouse={self.conn.extra_dejson['warehouse']}&role={self.conn.extra_dejson['role']}" # noqa
except KeyError: # auto generated connection kwargs Snowflake provider < 4.0.0
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a more direct approach to check package versions here would be better, something like the answer here:
https://stackoverflow.com/a/32965521

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense, yes. Changed it :)

One issue: referencing the snowflake package is breaking the unit testing. I tried using the package import and then .version but the snowflake package does not seem to have that as an attribute.

The code itself works fine. Just the test is understandably unhappy.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe @kaxil has an idea of how packages can be brought in for testing? I haven't done anything like that before afaik

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I think we just have to install apache-airflow-providers-snowflake as part of the pip install in the testing suite.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok I was wrong about the package approach -- totally forgot about .get() even though I used it today 😓

@@ -21,7 +21,9 @@
from datetime import datetime
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union

import airflow.providers.snowflake # noqa
Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes snowflake provider a hard dependency for installing great-expectations.

Do we really want that?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is not used anywhere as well, why do we need this import line?

Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't, just took a look at your suggested change and that's definitely the right approach.

@kaxil kaxil merged commit 4f2b4fd into astronomer:main Jan 10, 2023
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.

Snowflake connection failure when only using the Airflow UI fields to set the connection
3 participants