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
8 changes: 6 additions & 2 deletions providers/apache/impala/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ dependencies = [
"kerberos" = [
"kerberos>=1.3.0",
]
"sqlalchemy" = [
"sqlalchemy>=1.4.49",
]

[dependency-groups]
dev = [
Expand All @@ -77,8 +80,9 @@ dev = [
"apache-airflow-devel-common",
"apache-airflow-providers-common-sql",
# Additional devel dependencies (do not remove this line and add extra development dependencies)
"kerberos>=1.3.0",
"apache-airflow-providers-common-sql[pandas,polars]"
"apache-airflow-providers-apache-impala[kerberos]",
"apache-airflow-providers-common-sql[pandas,polars]",
"apache-airflow-providers-apache-impala[sqlalchemy]",
]

# To build docs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
from typing import TYPE_CHECKING

from impala.dbapi import connect
from sqlalchemy.engine import URL

from airflow.exceptions import AirflowOptionalProviderFeatureException
from airflow.providers.common.sql.hooks.sql import DbApiHook

if TYPE_CHECKING:
from impala.interface import Connection
from sqlalchemy.engine import URL


class ImpalaHook(DbApiHook):
Expand All @@ -50,6 +51,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(
"The 'sqlalchemy' library is required to use this feature. "
"Please install it with: pip install 'apache-airflow-providers-apache-impala[sqlalchemy]'"
) from err

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

Expand Down