ambika-garg commented on code in PR #36622:
URL: https://github.com/apache/airflow/pull/36622#discussion_r1444840503
##########
airflow/providers/microsoft/azure/hooks/synapse.py:
##########
@@ -56,8 +56,64 @@ class AzureSynapseSparkBatchRunStatus:
TERMINAL_STATUSES = {SUCCESS, DEAD, KILLED, ERROR}
+class BaseAzureSynapseHook(BaseHook):
+ """
+ A base hook class to create session and connection to Azure Synapse using
connection id.
+
+ :param azure_synapse_conn_id: The :ref:`Azure Synapse connection
id<howto/connection:synapse>`.
+ """
+
+ conn_type: str = "azure_synapse"
+ conn_name_attr: str = "azure_synapse_conn_id"
+ default_conn_name: str = "azure_synapse_default"
+ hook_name: str = "Azure Synapse"
+
+ @classmethod
+ @add_managed_identity_connection_widgets
+ def get_connection_form_widgets(cls) -> dict[str, Any]:
+ """Returns connection widgets to add to connection form."""
+ from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
+ from flask_babel import lazy_gettext
+ from wtforms import StringField
+
+ return {
+ "tenantId": StringField(lazy_gettext("Tenant ID"),
widget=BS3TextFieldWidget()),
+ "subscriptionId": StringField(lazy_gettext("Subscription ID"),
widget=BS3TextFieldWidget()),
+ }
+
+ @classmethod
+ def get_ui_field_behaviour(cls) -> dict[str, Any]:
+ """Returns custom field behaviour."""
+ return {
+ "hidden_fields": ["schema", "port", "extra"],
+ "relabeling": {
+ "login": "Client ID",
+ "password": "Secret",
+ "host": "Synapse Workspace URL",
+ },
+ }
+
+ def __init__(self, azure_synapse_conn_id: str = default_conn_name) -> None:
+ super().__init__()
+ self.conn_id = azure_synapse_conn_id
+
+ def get_conn(self):
+ raise NotImplementedError
+
+ def _get_field(self, extras: dict, field_name: str) -> str:
+ return get_field(
+ conn_id=self.conn_id,
+ conn_type=self.conn_type,
+ extras=extras,
+ field_name=field_name,
+ )
+
+
class AzureSynapseHook(BaseHook):
"""
+
+ This claas is deprecated. Please use `AzureSynapseSparkHook` instead.
Review Comment:
Can I deprecate the current class now and release the new version later?
--
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]