This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new b3667fc9c12 sqlalchemy optional in presto provider (#59944)
b3667fc9c12 is described below
commit b3667fc9c126570947063e1ba05964c92b60b6cb
Author: Steve Ahn <[email protected]>
AuthorDate: Tue Dec 30 16:33:56 2025 -0800
sqlalchemy optional in presto provider (#59944)
---
providers/presto/pyproject.toml | 4 ++++
providers/presto/src/airflow/providers/presto/hooks/presto.py | 11 ++++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/providers/presto/pyproject.toml b/providers/presto/pyproject.toml
index b151c69e964..c87ca06fcf1 100644
--- a/providers/presto/pyproject.toml
+++ b/providers/presto/pyproject.toml
@@ -74,6 +74,9 @@ dependencies = [
"google" = [
"apache-airflow-providers-google"
]
+"sqlalchemy" = [
+ "sqlalchemy>=1.4.49",
+]
[dependency-groups]
dev = [
@@ -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:
diff --git a/providers/presto/src/airflow/providers/presto/hooks/presto.py
b/providers/presto/src/airflow/providers/presto/hooks/presto.py
index 002ec12efb1..79d5e956226 100644
--- a/providers/presto/src/airflow/providers/presto/hooks/presto.py
+++ b/providers/presto/src/airflow/providers/presto/hooks/presto.py
@@ -25,7 +25,6 @@ import prestodb
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
@@ -42,6 +41,8 @@ else:
)
if TYPE_CHECKING:
+ from sqlalchemy.engine import URL
+
from airflow.models import Connection
T = TypeVar("T")
@@ -150,6 +151,14 @@ class PrestoHook(DbApiHook):
@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 {}