Copilot commented on code in PR #64938:
URL: https://github.com/apache/airflow/pull/64938#discussion_r3066486693


##########
providers/google/src/airflow/providers/google/cloud/operators/bigquery.py:
##########
@@ -93,22 +83,23 @@ class IfExistAction(enum.Enum):
     SKIP = "skip"
 
 
-class _BigQueryHookWithFlexibleProjectId(BigQueryHook):
-    @property
-    def project_id(self) -> str:
-        _, project_id = self.get_credentials_and_project_id()
-        return project_id or PROVIDE_PROJECT_ID
+class _BigQueryDbHookMixin:
+    def get_db_hook(self: BigQueryCheckOperator) -> BigQueryHook:  # 
type:ignore[misc]
+        """Get BigQuery DB Hook."""
+        from airflow.providers.google.cloud.hooks.bigquery import BigQueryHook
 
-    @project_id.setter
-    def project_id(self, value: str) -> None:
-        cached_creds, _ = self.get_credentials_and_project_id()
-        self._cached_project_id = value or PROVIDE_PROJECT_ID
-        self._cached_credntials = cached_creds
+        class _BigQueryHookWithFlexibleProjectId(BigQueryHook):
+            @property
+            def project_id(self) -> str:
+                _, project_id = self.get_credentials_and_project_id()
+                return project_id or PROVIDE_PROJECT_ID
 
+            @project_id.setter
+            def project_id(self, value: str) -> None:
+                cached_creds, _ = self.get_credentials_and_project_id()
+                self._cached_project_id = value or PROVIDE_PROJECT_ID
+                self._cached_credntials = cached_creds

Review Comment:
   In `_BigQueryHookWithFlexibleProjectId.project_id` setter, this assigns to 
`self._cached_credntials`, but the base hook caching attribute is 
`_cached_credentials` (see 
`airflow/providers/google/common/hooks/base_google.py`). As written, the 
credentials cache is not updated/used and a new misspelled attribute is created 
instead. Update this to write to the correct `_cached_credentials` attribute 
(and consider keeping backwards-compat only if needed).
   ```suggestion
                   self._cached_credentials = cached_creds
   ```



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