Skip to content

Conversation

@Sharashchandra
Copy link
Contributor

This PR enhances the SnowflakeHook in the Airflow repo by completing the OAuth authentication flow. It adds logic to fetch the access token using the refresh_token, client_id, and client_secret, which are already managed in the extras of the Snowflake connection object.

Changes & Fixes:
Implements logic to exchange the refresh_token for a new access token before establishing a connection.
Resolves an issue where using refresh_token, client_id, and client_secret directly with SnowflakeHook results in the error:
main/newsfragments).

snowflake.connector.errors.DatabaseError: 250001 (08001): None: Failed to connect to DB: <account>.snowflakecomputing.com:443. Invalid OAuth access token.

@boring-cyborg boring-cyborg bot added the provider:snowflake Issues related to Snowflake provider label Feb 25, 2025
Copy link
Contributor

@bugraoz93 bugraoz93 left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for the changes! Only have a small nit.

Comment on lines 321 to 322
access_token = self.get_oauth_token(conn_config=conn_config)
conn_config["token"] = access_token
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
access_token = self.get_oauth_token(conn_config=conn_config)
conn_config["token"] = access_token
conn_config["token"] = self.get_oauth_token(conn_config=conn_config)

Not a blocker but a small nit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made this change and pushed.

Copy link
Contributor

@bugraoz93 bugraoz93 left a comment

Choose a reason for hiding this comment

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

Amazing thanks!

@potiuk
Copy link
Member

potiuk commented Feb 25, 2025

conflicts :(

@Sharashchandra Sharashchandra force-pushed the snowflake_hook_oauth_no_merge_commit branch from 90fba16 to 2791f73 Compare February 26, 2025 02:14
@Sharashchandra
Copy link
Contributor Author

Merge conflicts have been resolved!

@Sharashchandra Sharashchandra force-pushed the snowflake_hook_oauth_no_merge_commit branch 3 times, most recently from e130f3f to 64c4213 Compare February 26, 2025 17:20
@Sharashchandra Sharashchandra force-pushed the snowflake_hook_oauth_no_merge_commit branch from 64c4213 to 437b17a Compare February 27, 2025 12:13
Sharashchandra and others added 14 commits February 27, 2025 17:54
* Edge worker maintenance mode can be set from cli

* apply review findings

* add misc

* delete outdated code part

---------

Co-authored-by: Majoros Donat (XC-DX/EET2-Bp) <donat.majoros2@hu.bosch.com>
The apache#47105 wrongly assumed that the new ydb version caused the problem
with grpc.io, it turned out however that the root cause was wrong
grpcio specification for yandexcloud - where grpcio requirement
did not match runtime check for version.

Excluding the versions of yandexcloud (and asking them to yank those
versions) should help in solving the problem and it should not
limit users to upgrade to newer versions of yandexcloud (when they
are not using apache.beam or other libraries that limit grpcio to
< 1.68.1)
* Add Mapped Task Summary page

* Remove mapped task instance lookup in dag breadcrumb
`airflow webserver` was added to the list of legacy commands, which
means users will be informed of the replacement instead of just getting
a generic error:

```
$ airflow webserver
Usage: airflow [-h] GROUP_OR_COMMAND ...
...
airflow command error: argument GROUP_OR_COMMAND: Command `airflow webserver` has been removed. Please use `airflow api-server`, see help above.
```
The intent behind this isinstance check was to deal with this, but it was
missed that you can't import it on Airflow 3. Oops

Closes apache#47139
This included renaming the following args to better match
fastapi/uvicorn:
  - `--hostname` -> `--host`
  - `--debug` -> `--dev`

The following config options were removed (there isn't an equivalent
currently):
  - `[webserver] error_logfile`
  - `[webserver] access_logformat`

The following config options were moved/renamed to the `api` section.
  - `[webserver] web_server_host` has been moved to `[api] host`
  - `[webserver] web_server_port` has been moved to `[api] port`
  - `[webserver] workers` has been moved to `[api] workers`
  - `[webserver] web_server_worker_timeout` has been moved to `[api] worker_timeout`
  - `[webserver] web_server_ssl_cert` has been moved to `[api] ssl_cert`
  - `[webserver] web_server_ssl_key` has been moved to `[api] ssl_key`
  - `[webserver] access_logfile` has been moved to `[api] access_logfile`
…pache#47155)

When provider.yaml or pypyroject.toml changes for a provider, that
should trigger CI-image bound static checks - because only there
we verify provider.yaml and it might trigger CI image build to get
new dependencies that might fail the CI image build.
vatsrahul1001 and others added 12 commits February 28, 2025 09:39
* WIP: List Backfills

* Resolve review comments

* Removed id and split dates into from-to

* Updated duration

* Append s to duration field

* Remove sorting and adding new columns

* Updated icon in dag
The Tasksdk datamodel codegen has not been fixed and when new
version was released it caused pre-commit to fail. Fixing it,
to specific version should add reproducibility, at the same time
dependabot of ours will create PRs when new version is released
so we are not loosing auto-upgrade features.
…ache#47148)

* Add methodtools as a dependency of the common-sql provider

Since `apache-airflow-providers-common-sql==1.23.0`, released on 26 February 2025, users started facing the error:

```
    from cosmos.operators._asynchronous.bigquery import DbtRunAirflowAsyncBigqueryOperator
cosmos/operators/_asynchronous/bigquery.py:8: in <module>
    from airflow.providers.google.cloud.operators.bigquery import BigQueryInsertJobOperator
../../../.local/share/hatch/env/virtual/astronomer-cosmos/Za_bFbg4/tests.py3.12-2.9/lib/python3.12/site-packages/airflow/providers/google/cloud/operators/bigquery.py:32: in <module>
    from airflow.providers.common.sql.operators.sql import (  # type: ignore[attr-defined] # for _parse_boolean
../../../.local/share/hatch/env/virtual/astronomer-cosmos/Za_bFbg4/tests.py3.12-2.9/lib/python3.12/site-packages/airflow/providers/common/sql/operators/sql.py:[29](https://github.com/astronomer/astronomer-cosmos/actions/runs/13544957799/job/37854234771#step:6:30): in <module>
    from airflow.providers.common.sql.hooks.sql import DbApiHook, fetch_all_handler, return_single_query_results
../../../.local/share/hatch/env/virtual/astronomer-cosmos/Za_bFbg4/tests.py3.12-2.9/lib/python3.12/site-packages/airflow/providers/common/sql/hooks/sql.py:37: in <module>
    from methodtools import lru_cache
E   ModuleNotFoundError: No module named 'methodtools'
```

It seems this started happening since apache#41327.

This PR aims to solve this issue.

Closes: apache#47147

* Fix linting

* Revert change to provider.yaml and applyc hange to pyproject.toml
This makes the process of developing and debugging much more plesant, as
without this we get 0 logging (just a "500" access log line) in case of an
unhandled exception.
* Update INTHEWILD.md

This PR adds Blue3 Investimentos to the INTHEWILD.md file, which tracks organizations using this project in production. Blue3 Investimentos is a financial investment company that has incorporated this tool into their workflow.

* Update INTHEWILD.md

Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>

* sort correct

---------

Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
Common.sql self-deprecated itself after apache#43747 by importing handlers
from the old location.
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
@Sharashchandra
Copy link
Contributor Author

Closing this PR since I messed up with updating the branch, will fix this and reopen the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

provider:snowflake Issues related to Snowflake provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.