File tree Expand file tree Collapse file tree
src/airflow/providers/vertica/hooks Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,6 +63,13 @@ dependencies = [
6363 " vertica-python>=1.3.0" ,
6464]
6565
66+ # The optional dependencies should be modified in place in the generated file
67+ # Any change in the dependencies is preserved when the file is regenerated
68+ [project .optional-dependencies ]
69+ sqlalchemy = [
70+ " sqlalchemy>=1.4.49" ,
71+ ]
72+
6673[dependency-groups ]
6774dev = [
6875 " apache-airflow" ,
@@ -71,6 +78,7 @@ dev = [
7178 " apache-airflow-providers-common-sql" ,
7279 # Additional devel dependencies (do not remove this line and add extra development dependencies)
7380 " apache-airflow-providers-common-sql[pandas,polars]" ,
81+ " apache-airflow-providers-vertica[sqlalchemy]"
7482]
7583
7684# To build docs:
Original file line number Diff line number Diff line change 1717from __future__ import annotations
1818
1919from collections .abc import Callable , Iterable , Mapping
20- from typing import Any , overload
20+ from typing import TYPE_CHECKING , Any , overload
2121
22- from sqlalchemy .engine import URL
2322from vertica_python import connect
2423
24+ from airflow .exceptions import AirflowOptionalProviderFeatureException
2525from airflow .providers .common .sql .hooks .handlers import fetch_all_handler
2626from airflow .providers .common .sql .hooks .sql import DbApiHook
2727
28+ if TYPE_CHECKING :
29+ from sqlalchemy .engine import URL
30+
2831
2932def vertica_fetch_all_handler (cursor ) -> list [tuple ] | None :
3033 """
@@ -137,6 +140,13 @@ def get_conn(self) -> connect:
137140 @property
138141 def sqlalchemy_url (self ) -> URL :
139142 """Return a SQLAlchemy URL object with properly formatted query parameters."""
143+ try :
144+ from sqlalchemy .engine import URL
145+ except (ImportError , ModuleNotFoundError ) as err :
146+ raise AirflowOptionalProviderFeatureException (
147+ "The 'sqlalchemy' library is required to use this feature. "
148+ "Please install it with: pip install 'apache-airflow-providers-vertica[sqlalchemy]'"
149+ ) from err
140150 conn = self .get_connection (self .get_conn_id ())
141151 extra = conn .extra_dejson or {}
142152
You can’t perform that action at this time.
0 commit comments