You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Snowflake Provider - Hook's support for not providing a region is broken when using SQLAlchemy #20032
When connecting to Snowflake via SQLAlchemy using the Snowflake Hook, I get an error that the URL is not valid because my Snowflake instance is in US West 2 (Oregon) which means I don't provide a region explicitly. Snowflake's documentation says:
If the account is located in the AWS US West (Oregon) region, no additional segments are required and the URL would be xy12345.snowflakecomputing.com
The error is that xy12345..snowflakecomputing.com is not a valid URL (note the double-dot caused by the lack of a region).
What you expected to happen
I expect the connection to be successful.
How to reproduce
You can use the default snowflake connection if you have one defined and see this problem with the following one-liner:
Using version 2.1.1 of the Snowflake provider with version 2.2.1 of Airflow is currently a viable workaround so for now I am just avoiding the update to the provider.
I narrowed down the scope of our issue here. Once I am inside the virtual environment, and I try to import the same SQLAlchemy package, I run into the same error:
`root@66ecbec1a1f0:/opt/airflow# python
Python 3.8.12 (default, Nov 17 2021, 17:26:17)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
from snowflake.sqlalchemy import URL
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.8/site-packages/snowflake/sqlalchemy/init.py", line 25, in
from . import base, snowdialect
File "/usr/local/lib/python3.8/site-packages/snowflake/sqlalchemy/base.py", line 17, in
from .custom_commands import AWSBucket, AzureContainer, ExternalStage
File "/usr/local/lib/python3.8/site-packages/snowflake/sqlalchemy/custom_commands.py", line 14, in
from sqlalchemy.sql.roles import FromClauseRole
ModuleNotFoundError: No module named 'sqlalchemy.sql.roles'
`
It looks like there is a bug with SQLAlchemy 1.3.24, which is a dependency for Flask-AppBuilder. See 1621 and 953.
If you have some time spare, can one of you please try to import this package in your local venv and let me know if you face the same issue? @potiuk@mik-laj
This package is not being used anywhere else in the entire airflow repository.
Unfortunately, Snowflake incorrectly marked the version requirements in one release of snowflake-sqlalchemy and after fixing the problem, they didn't mark the release as yanked, so pip downloads invalid dependency set.
@mik-laj any suggestions to overcome celery dependency issues?
Searched the forum and online and found no open bugs related to it. Happens when running sudo ./breeze initialize-local-virtualenv --python 3.8 and the virtual environment has the celery version of 5.2.1.
from celery import Celery, Task, states as celery_states ModuleNotFoundError: No module named 'celery'
My apologies for asking again, I am contributing to this repo for the first time. Will follow this and install the dependencies. Thank you for the help and patience @mik-laj.
@mik-laj a couple points for clarification. I added a unit test for the fix and it passed. I tried using the snowflake.sqlalchemy.URL, but during running pytest, it caused issues with generating the URL with nested dict values for session_parameters, so I reverted it to use string format, as is currently being used in the mainline branch.
After pulling my hair out for days with this exact Snowflake URL issue, this post was a lifesaver! That double-dot bug is so subtle but completely breaks everything. Here's what worked for me:
Quick Fix: Confirmed rolling back to snowflake-provider 2.1.1 works as a temporary solution (pip install apache-airflow-provider-snowflake==2.1.1)
Alternative Approach: Found that explicitly setting region=us-west-2 in the connection extras (even though Oregon shouldn't need it) also resolves it
Pro Tip: For anyone setting up fresh, make sure to use the full connection string format:
account.user@xy12345.us-west-2.snowflakecomputing.com
(Yes, even for Oregon - seems counterintuitive but prevents issues)
Question for OP: Did you find any other workarounds before discovering the provider version fix? I'm curious if modifying the hook directly would've worked.
— DataPipesDreamer (Running Airflow 2.3 with Snowflake since 2021)
P.S. For new users hitting this, don't forget to pip install apache-airflow [google,snowflake] with the latest constraints file - dependency management is half the battle!
New chat
Activity
boring-cyborg commentedon Dec 4, 2021
Thanks for opening your first issue here! Be sure to follow the issue template!
potiuk commentedon Dec 4, 2021
Why don't you submit a PR with a fix @mattpolzin ? Sounds lke an eaasy fix.
mattpolzin commentedon Dec 4, 2021
I appreciate the encouragement! I've got a lot of projects in progress right now so I don't think I'll find time to get set up here as well.
potiuk commentedon Dec 4, 2021
I marked it as good-first-issue, so maybe someone else will pick it up then !
harishkrao commentedon Dec 5, 2021
Is this available to pick up and implement?
potiuk commentedon Dec 5, 2021
Sure @harishkrao . Assigned you.
potiuk commentedon Dec 5, 2021
But maybe @mik-laj would like to do it firsst - so agree between yourselves ;)
12 remaining items
harishkrao commentedon Dec 12, 2021
I narrowed down the scope of our issue here. Once I am inside the virtual environment, and I try to import the same SQLAlchemy package, I run into the same error:
`root@66ecbec1a1f0:/opt/airflow# python
Python 3.8.12 (default, Nov 17 2021, 17:26:17)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
If you have some time spare, can one of you please try to import this package in your local venv and let me know if you face the same issue? @potiuk @mik-laj
This package is not being used anywhere else in the entire airflow repository.
mik-laj commentedon Dec 13, 2021
@harishkrao See: snowflakedb/snowflake-sqlalchemy#234
To use URL class, you need to run:
Unfortunately, Snowflake incorrectly marked the version requirements in one release of
snowflake-sqlalchemyand after fixing the problem, they didn't mark the release as yanked, so pip downloads invalid dependency set.mik-laj commentedon Dec 13, 2021
I pushed a fix: #20245
harishkrao commentedon Dec 13, 2021
Thanks very much for letting me know and for pushing the fix @mik-laj :) I will use the above versions.
Edit: It worked 👍 Thanks a lot!
harishkrao commentedon Dec 13, 2021
@mik-laj any suggestions to overcome celery dependency issues?
Searched the forum and online and found no open bugs related to it. Happens when running
sudo ./breeze initialize-local-virtualenv --python 3.8and the virtual environment has the celery version of5.2.1.from celery import Celery, Task, states as celery_states ModuleNotFoundError: No module named 'celery'mik-laj commentedon Dec 13, 2021
See: https://airflow.apache.org/docs/apache-airflow/stable/installation/installing-from-pypi.html
harishkrao commentedon Dec 13, 2021
My apologies for asking again, I am contributing to this repo for the first time. Will follow this and install the dependencies. Thank you for the help and patience @mik-laj.
harishkrao commentedon Dec 15, 2021
Just an info - I am working on this, my laptop crashed, so I have to setup the environment in another laptop and continue, will get back soon.
harishkrao commentedon Dec 20, 2021
Environment is configured, working on this, will get back in a day or two.
harishkrao commentedon Dec 22, 2021
Made changes for the fix. Preparing the PR now.
@mik-laj a couple points for clarification. I added a unit test for the fix and it passed. I tried using the
snowflake.sqlalchemy.URL, but during runningpytest, it caused issues with generating the URL with nested dict values for session_parameters, so I reverted it to use string format, as is currently being used in the mainline branch.mik-laj commentedon Dec 26, 2021
@harishkrao Do you need help with preparing a PR?
harishkrao commentedon Dec 26, 2021
@mik-laj Thank you for offering help, had to attend to something else until now. I will follow the steps in the guide and get back to you soon.
harishkrao commentedon Dec 27, 2021
Just opened a PR, thank you for reviewing @mik-laj!
new-php commentedon Mar 25, 2025
After pulling my hair out for days with this exact Snowflake URL issue, this post was a lifesaver! That double-dot bug is so subtle but completely breaks everything. Here's what worked for me:
Question for OP: Did you find any other workarounds before discovering the provider version fix? I'm curious if modifying the hook directly would've worked.
— DataPipesDreamer (Running Airflow 2.3 with Snowflake since 2021)
P.S. For new users hitting this, don't forget to pip install apache-airflow [google,snowflake] with the latest constraints file - dependency management is half the battle!
New chat