Vamsi-klu opened a new pull request, #69747:
URL: https://github.com/apache/airflow/pull/69747

   ## Problem
   Databricks connection with http_path in extra JSON (common UI path) works 
for get_conn() but fails for sqlalchemy_url / get_uri() because latter only 
reads self._http_path (init arg), ignoring extra_dejson["http_path"] and 
sql_endpoint_name resolution.
   
   Root cause in 
providers/databricks/src/airflow/providers/databricks/hooks/databricks_sql.py:
   - get_conn correctly resolves explicit arg, sql_endpoint_name API, 
extra_dejson
   - sqlalchemy_url buggy: only uses self._http_path
   
   Existing tests only supply explicit http_path, no extra path test.
   
   ## What I did
   - Added helper _resolve_http_path(allow_endpoint_lookup bool) that:
     - returns cached _http_path if set (explicit wins)
     - checks extra_dejson["http_path"] and caches
     - if allow_endpoint_lookup and sql_endpoint_name, calls API
   - Updated get_conn to use helper with allow_endpoint_lookup=True
   - Updated sqlalchemy_url to use helper with allow_endpoint_lookup=False 
(offline-safe, no REST call) per reviewer comment from draft PR #69037
   - Preserves explicit wins logic, avoids unexpected API call in property
   
   ## Impact
   - Fixes SQLAlchemy usage when connection defined via UI extra (common case)
   - get_uri() auto-fixed via sqlalchemy_url
   - If only sql_endpoint_name set without get_conn first, property returns 
None (old behavior, acceptable) - user should call get_conn first or use 
explicit http_path
   - No breaking change, offline-safe
   
   ## Testing
   - uv run --project providers-databricks pytest 
providers/databricks/tests/unit/databricks/hooks/test_databricks_sql.py -k 
sqlalchemy_url → passed
   - Full file → 58 passed
   - Manual:
     - Extra http_path now present in sqlalchemy_url (was missing)
     - Explicit wins over extra
     - Endpoint-only stays offline-safe (no API call)
   
   Fixes: #69031
   
   ##### Was generative AI tooling used to co-author this PR?
   - [X] Yes — Muse Spark 1.1
   Generated-by: Muse Spark 1.1


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