rawwar commented on code in PR #44960:
URL: https://github.com/apache/airflow/pull/44960#discussion_r1889627914


##########
providers/src/airflow/providers/databricks/operators/databricks.py:
##########
@@ -1037,17 +1040,21 @@ def _get_hook(self, caller: str) -> DatabricksHook:
             caller=caller,
         )
 
-    def _get_databricks_task_id(self, task_id: str) -> str:
-        """Get the databricks task ID using dag_id and task_id. Removes 
illegal characters."""
-        task_id = f"{self.dag_id}__{task_id.replace('.', '__')}"
-        if len(task_id) > 100:
-            self.log.warning(
-                "The generated task_key '%s' exceeds 100 characters and will 
be truncated by the Databricks API. "
-                "This will cause failure when trying to monitor the task. 
task_key is generated by ",
-                "concatenating dag_id and task_id.",
-                task_id,
+    @cached_property
+    def databricks_task_key(self) -> str:
+        return self._generate_databricks_task_key()
+
+    def _generate_databricks_task_key(self, task_id: str | None = None) -> str:
+        """Create a databricks task key using the hash of dag_id and 
task_id."""
+        if self._databricks_task_key is None:

Review Comment:
   I think, we also have to cover the case when the given databricks_task_key 
has a length greater than 100. Alternative to this is to not let users pass the 
key and we auto-generate it using hash of dag + task id



##########
providers/src/airflow/providers/databricks/operators/databricks.py:
##########
@@ -1037,17 +1040,21 @@ def _get_hook(self, caller: str) -> DatabricksHook:
             caller=caller,
         )
 
-    def _get_databricks_task_id(self, task_id: str) -> str:
-        """Get the databricks task ID using dag_id and task_id. Removes 
illegal characters."""
-        task_id = f"{self.dag_id}__{task_id.replace('.', '__')}"
-        if len(task_id) > 100:
-            self.log.warning(
-                "The generated task_key '%s' exceeds 100 characters and will 
be truncated by the Databricks API. "
-                "This will cause failure when trying to monitor the task. 
task_key is generated by ",
-                "concatenating dag_id and task_id.",
-                task_id,
+    @cached_property
+    def databricks_task_key(self) -> str:
+        return self._generate_databricks_task_key()
+
+    def _generate_databricks_task_key(self, task_id: str | None = None) -> str:
+        """Create a databricks task key using the hash of dag_id and 
task_id."""
+        if self._databricks_task_key is None:

Review Comment:
   I think, we also have to cover the case when the given databricks_task_key 
has a length greater than 100. Alternative to this is to not let users pass the 
task_key and we auto-generate it using hash of dag + task id



-- 
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]

Reply via email to