Skip to content
Open
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
16 changes: 14 additions & 2 deletions providers/exasol/src/airflow/providers/exasol/hooks/exasol.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@
import pyexasol
from deprecated import deprecated
from pyexasol import ExaConnection, ExaStatement
from sqlalchemy.engine import URL

from airflow.exceptions import AirflowProviderDeprecationWarning
try:
from sqlalchemy.engine import URL
except ImportError:
URL = None

from airflow.exceptions import AirflowOptionalProviderFeatureException, AirflowProviderDeprecationWarning
from airflow.providers.common.sql.hooks.handlers import return_single_query_results
from airflow.providers.common.sql.hooks.sql import DbApiHook

Expand Down Expand Up @@ -96,6 +100,10 @@ def sqlalchemy_url(self) -> URL:
:return: the extracted sqlalchemy.engine.URL object.
"""
if URL is None:
raise AirflowOptionalProviderFeatureException(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
raise AirflowOptionalProviderFeatureException(
raise AirflowOptionalProviderFeatureException(
"sqlalchemy is required for SQL filter clause generation. "
"Install it with: pip install 'apache-airflow-providers-exasol[sqlalchemy]'"
)

Copy link
Contributor

Choose a reason for hiding this comment

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

In the case described above you need to add it as optional dependency in pyproject.toml as well.

"The 'sqlalchemy' library is required to use 'sqlalchemy_url'."
)
connection = self.connection
query = connection.extra_dejson
query = {k: v for k, v in query.items() if k.lower() != "sqlalchemy_scheme"}
Expand All @@ -115,6 +123,10 @@ def get_uri(self) -> str:
:return: the extracted uri.
"""
if URL is None:
raise AirflowOptionalProviderFeatureException(
"The 'sqlalchemy' library is required to render the connection URI."
)
return self.sqlalchemy_url.render_as_string(hide_password=False)

def _get_pandas_df(
Expand Down