mwojtyczka commented on code in PR #63775:
URL: https://github.com/apache/airflow/pull/63775#discussion_r2980147494


##########
providers/databricks/src/airflow/providers/databricks/hooks/databricks_base.py:
##########
@@ -386,14 +411,14 @@ async def _a_get_aad_token(self, resource: str) -> str:
 
             async for attempt in self._a_get_retry_object():
                 with attempt:

Review Comment:
   `a_host()` duplicates the logic of the sync `host` property exactly. If the 
host-resolution logic ever changes (e.g. a new priority for extra fields), it 
needs updating in two places. Consider extracting to a shared helper:
   ```python
   def _resolve_host_from_conn(self, conn) -> str | None:
       if "host" in conn.extra_dejson:
           return self._parse_host(conn.extra_dejson["host"])
       elif conn.host:
           return self._parse_host(conn.host)
       return None
   ```
   Then both `host` and `a_host` delegate to it.



##########
providers/databricks/src/airflow/providers/databricks/hooks/databricks_base.py:
##########
@@ -474,7 +500,7 @@ async def _a_get_aad_token_for_default_az_credential(self, 
resource: str) -> str
                 DefaultAzureCredential as AsyncDefaultAzureCredential,
             )
 

Review Comment:
   `_get_connection_attr("login")` was replaced with `conn.login or ""`. Please 
verify these are equivalent — `_get_connection_attr` may have additional 
null-handling or logging beyond a plain attribute access. If they are 
equivalent, a brief comment here would help future readers understand why the 
simpler form is safe.



##########
providers/databricks/tests/unit/databricks/hooks/test_databricks.py:
##########
@@ -732,6 +732,21 @@ def test_cancel_run(self, mock_requests):
             timeout=self.hook.timeout_seconds,
         )
 
+    @pytest.mark.asyncio
+    
@mock.patch("airflow.providers.databricks.hooks.databricks_base.aiohttp.ClientSession.post")
+    async def test_a_cancel_run(self, mock_post):
+        mock_post.return_value.__aenter__.return_value.json = 
AsyncMock(return_value=GET_RUN_RESPONSE)
+        mock_post.return_value.__aenter__.return_value.status = 200

Review Comment:
   The mock return value uses `GET_RUN_RESPONSE` (a run-state response body), 
but `cancel_run` returns an empty dict `{}`. The return value is unused so this 
is harmless, but `AsyncMock(return_value={})` would be more accurate and 
consistent with `test_a_cancel_sql_statement` below.



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