buu-nguyen commented on issue #33400: URL: https://github.com/apache/airflow/issues/33400#issuecomment-1848596780
> Possible workaround: > > * Step1: Extend a BigQueryHook class and overwrite [`GoogleBaseHook#scopes`](https://github.com/apache/airflow/blob/0f73647bdab79ac6c30961222924f6166f75b55a/airflow/providers/google/common/hooks/base_google.py#L395-L404) method as follows: > ```python > class BigQueryHookWithScopes(BigQueryHook): > def __init__(self, scopes: Sequence[str], *args, **kwargs): > super().__init__(*args, **kwargs) > self._scopes = scopes > > @property > def scopes(self) -> Sequence[str]: > return self._scopes > ``` > > * Step2: Extend a BigQuery related Operators to use the above hook as follows: > ```python > class BigQueryExecuteQueryOperatorWithScope(BigQueryExecuteQueryOperator): > def __init__(self, scopes, *args, **kwargs): > super().__init__(*args, **kwargs) > self.scopes = scopes > > def execute(self, context): > self.hook = BigQueryHookWithScopes( > scopes=self.scopes, > gcp_conn_id=self.gcp_conn_id, > use_legacy_sql=self.use_legacy_sql, > delegate_to=self.delegate_to, > location=self.location, > impersonation_chain=self.impersonation_chain, > ) > super().execute(context) > ``` Hey, thanks for the workaround. I just noticed that GoogleBaseHook seems to already pick up scopes from connection's field(https://github.com/apache/airflow/blob/0f73647bdab79ac6c30961222924f6166f75b55a/airflow/providers/google/common/hooks/base_google.py#L402C44-L402C44). Is there a specific reason to override it? Just curious about this approach. -- 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: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org