RehanAhmad25 commented on code in PR #77423:
URL: https://github.com/apache/airflow/pull/77423#discussion_r4657614229
##########
providers/microsoft/mssql/src/airflow/providers/microsoft/mssql/hooks/mssql.py:
##########
@@ -37,6 +39,170 @@
from airflow.providers.common.sql.dialects.dialect import Dialect
from airflow.providers.openlineage.sqlparser import DatabaseInfo
+# Connection extras that are handled by the hook itself and must never reach
the DBAPI driver.
+_AIRFLOW_ONLY_EXTRAS = frozenset({"sqlalchemy_scheme", "dbapi_driver"})
+
+
+class _DbApiDriver(ABC):
+ """
+ Behaviour of ``MsSqlHook`` that depends on its ``dbapi_driver``.
+
+ The defaults are the plain DB-API behaviour, a driver only overrides what
it does differently.
+ To add a driver, subclass this and add an instance to ``_DRIVERS``.
+ """
+
+ name: str
+ default_sqlalchemy_scheme: str
+ placeholder = "%s"
+
+ @abstractmethod
+ def connect(self, connection: Connection, database: str | None) -> Any:
+ """Return a DB-API connection."""
+
+ def build_sqlalchemy_url(self, connection: Connection, database: str |
None, scheme: str) -> URL:
+ """Return the SQLAlchemy URL. Without one, the engine is built from
``MsSqlHook.get_uri()``."""
+ raise NotImplementedError
Review Comment:
Done in fb54251. The NotImplementedError now has a message ("The pymssql
driver builds no SQLAlchemy URL, use get_uri()."), and I did the optional one
too: the base rewrite_uri now raises NotImplementedError with a message instead
of returning the uri, since it was never reached. The test file is unchanged
and all 55 tests still pass in Breeze.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]