SameerMesiah97 opened a new pull request, #61757: URL: https://github.com/apache/airflow/pull/61757
**Description** This change adds cached resolution of the dbt Cloud `account_id` in `DbtCloudHook` for both synchronous and asynchronous execution paths. The two existing public APIs, `provide_account_id` and `fallback_to_default_account`, continue to provide a `account_id` when it is not explicitly supplied by the caller. These decorators now delegate to shared internal helpers that resolve the `account_id` from the configured Airflow connection and cache the result on the hook instance. The cached value is shared across synchronous and asynchronous resolution paths, ensuring consistent behavior when mixing sync and async hook methods on the same hook instance. **Rationale** The dbt Cloud `account_id` is a connection-derived value and is unlikely to change over the lifetime of a hook instance. Resolving it repeatedly on each method invocation does not provide additional correctness and results in unnecessary metadata database lookups. In addition, the dbt Cloud provider supports both synchronous and asynchronous hook methods. Without a shared cache, resolving the `account_id` in one execution context does not benefit the other, leading to duplicated lookups even within a single task execution. By caching the resolved `account_id` on the hook instance and sharing it across sync and async resolution paths, this change ensures the value is resolved at most once per hook instance while preserving existing behavior. **Tests** * Added a unit test asserting that synchronous `account_id` resolution is cached and does not perform repeated metadata DB lookups. * Added a unit test verifying equivalent caching behavior in the async resolution path. * Added a test ensuring the cache is shared between synchronous and asynchronous resolution, asserting that only a single metadata DB lookup occurs across both code paths. **Backwards Compatibility** This change does not alter the method signatures of any public APIs. The `provide_account_id` and `fallback_to_default_account` decorators remain unchanged. The asynchronous `account_id` resolution path now reuses the same cached value as the synchronous path and therefore behaves the same way from a caller perspective. -- 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]
