Fix async connection issue in BaseDatabricksHook - #72014
Open
Paxx2303 wants to merge 1 commit into
Open
Conversation
Fix RuntimeError when using async operators in triggerer environment. The issue was that async methods in BaseDatabricksHook were using the synchronous databricks_conn property, which calls BaseHook.get_connection(). When these methods are called from within a running event loop (e.g., in the triggerer process), this causes a RuntimeError because the sync method cannot be called directly from async context. Solution: - Add async method aget_connection() that wraps BaseHook.aget_connection() - Add async property a_databricks_conn for async access to the connection - Add async helper methods: _a_get_connection_attr(), _a_endpoint_url(), _a_is_aws_federation(), _a_get_required_client_id() - Update all async methods to use the async connection properties - Fix typo in proxies validation (invalid_ckeys -> invalid_keys) - Update _a_get_aad_token() to catch aiohttp.ClientResponseError instead of requests.HTTPError Fixes apache#71525
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix RuntimeError when using async operators in triggerer environment.
Problem
When
DatabricksExecutionTriggeror async operators useBaseDatabricksHookin the triggerer (where an event loop is running), it causes:Root Cause
Async methods in
BaseDatabricksHookwere using the synchronousdatabricks_connproperty which callsBaseHook.get_connection(). When called from within a running event loop, this causes the RuntimeError.Solution
aget_connection()async method wrappingBaseHook.aget_connection()a_databricks_connasync property for async connection access_a_get_connection_attr(),_a_endpoint_url(),_a_is_aws_federation(),_a_get_required_client_id()invalid_ckeys->invalid_keys)_a_get_aad_token()to catchaiohttp.ClientResponseErrorinstead ofrequests.HTTPErrorTests
Added comprehensive async tests including:
test_async_do_api_call_respects_schematest_async_do_api_call_only_existing_response_properties_are_readGenerated-by: Claude Code (Opus 5)