xlsongc opened a new pull request, #77479:
URL: https://github.com/apache/airflow/pull/77479

   `DatabricksSqlSensor` and `DatabricksPartitionSensor` passed their `handler` 
to `DatabricksSqlHook.run` only when `do_xcom_push` was `True`. Without a 
handler the hook returns `None`, so with `do_xcom_push=False`:
   
   - `DatabricksSqlSensor` never succeeds: `bool(None)` is `False`, so it pokes 
until `timeout` even when the query returns rows.
   - `DatabricksPartitionSensor` fails its first poke with `TypeError: 
'NoneType' object is not subscriptable`, because it reads the partition columns 
from the `DESCRIBE DETAIL` result.
   
   The handler fetches the rows the sensors check, and has nothing to do with 
XCom: a sensor pushes the return value of `poke`, not the query result. The 
condition looks copied from `DatabricksSqlOperator`, where the handler's result 
is what gets pushed. It has been there since the SQL sensor was added in 
#30477. Both sensors now always pass the handler.
   
   Each sensor gets a test that mocks `DatabricksSqlHook.run` with `autospec` 
and checks that the handler is passed when `do_xcom_push=False`. Both tests 
fail without the change. I also reproduced the bug through the real 
`DatabricksSqlHook.run`, mocking only the connection: for a query that returned 
one row, `poke` returned `True` with `do_xcom_push=True` and `False` with 
`do_xcom_push=False`.
   
   #77446 also changes `DatabricksPartitionSensor`, in the not-found path of 
`poke`. The two PRs touch different lines, and the new partition test sits at 
the end of the test class so that they do not conflict.
   
   Verification: the Databricks provider unit tests pass in breeze with Python 
3.11 (1279 passed). `prek` pre-commit and manual hooks, including 
`mypy-providers`, pass on the changed files.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (Opus 5.5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   


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