Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions providers/presto/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ dependencies = [
"google" = [
"apache-airflow-providers-google"
]
"sqlalchemy" = [
"sqlalchemy>=1.4.49",
]

[dependency-groups]
dev = [
Expand All @@ -85,6 +88,7 @@ dev = [
"apache-airflow-providers-google",
# Additional devel dependencies (do not remove this line and add extra development dependencies)
"apache-airflow-providers-common-sql[pandas,polars]",
"apache-airflow-providers-presto[sqlalchemy]",
]

# To build docs:
Expand Down
11 changes: 10 additions & 1 deletion providers/presto/src/airflow/providers/presto/hooks/presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from deprecated import deprecated
from prestodb.exceptions import DatabaseError
from prestodb.transaction import IsolationLevel
from sqlalchemy.engine import URL

from airflow.configuration import conf
from airflow.exceptions import AirflowOptionalProviderFeatureException, AirflowProviderDeprecationWarning
Expand All @@ -42,6 +41,8 @@
)

if TYPE_CHECKING:
from sqlalchemy.engine import URL

from airflow.models import Connection

T = TypeVar("T")
Expand Down Expand Up @@ -150,6 +151,14 @@ def get_conn(self) -> Connection:
@property
def sqlalchemy_url(self) -> URL:
"""Return a `sqlalchemy.engine.URL` object constructed from the connection."""
try:
from sqlalchemy.engine import URL
except (ImportError, ModuleNotFoundError) as err:
raise AirflowOptionalProviderFeatureException(
"SQLAlchemy is not installed. Please install it with "
"`pip install 'apache-airflow-providers-presto[sqlalchemy]'`."
) from err

conn = self.get_connection(self.get_conn_id())
extra = conn.extra_dejson or {}

Expand Down