This is an automated email from the ASF dual-hosted git repository.

kaxilnaik 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 0b7b133  Move DB call out of ``DatabricksHook.__init__`` (#18339)
0b7b133 is described below

commit 0b7b13372f6dbf18a35d5346d3955f65b31dd00d
Author: Kaxil Naik <[email protected]>
AuthorDate: Sat Sep 18 00:50:42 2021 +0100

    Move DB call out of ``DatabricksHook.__init__`` (#18339)
    
    Because of that using `DatabricksHook` in DAG files causes tons of issues 
as DB calls are made everytime files is parsed.
---
 airflow/providers/databricks/hooks/databricks.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/airflow/providers/databricks/hooks/databricks.py 
b/airflow/providers/databricks/hooks/databricks.py
index f83191e..5e7fc35 100644
--- a/airflow/providers/databricks/hooks/databricks.py
+++ b/airflow/providers/databricks/hooks/databricks.py
@@ -117,7 +117,7 @@ class DatabricksHook(BaseHook):
     ) -> None:
         super().__init__()
         self.databricks_conn_id = databricks_conn_id
-        self.databricks_conn = self.get_connection(databricks_conn_id)
+        self.databricks_conn = None
         self.timeout_seconds = timeout_seconds
         if retry_limit < 1:
             raise ValueError('Retry limit must be greater than equal to 1')
@@ -166,6 +166,8 @@ class DatabricksHook(BaseHook):
         """
         method, endpoint = endpoint_info
 
+        self.databricks_conn = self.get_connection(self.databricks_conn_id)
+
         if 'token' in self.databricks_conn.extra_dejson:
             self.log.info('Using token auth. ')
             auth = _TokenAuth(self.databricks_conn.extra_dejson['token'])

Reply via email to