KamranImaaz opened a new issue, #60687:
URL: https://github.com/apache/airflow/issues/60687
### Apache Airflow Provider(s)
google
### Versions of Apache Airflow Providers
_No response_
### Apache Airflow version
3.2.0
### Operating System
Windows(Local Development)
### Deployment
Official Apache Airflow Helm Chart
### Deployment details
_No response_
### What happened
In The Operator `Bigtable.py` contains several `try/except` block that are
not required and not expected in Operator Level as it Should be handled at Hook
Level.
Moreover The Exceptions raised at the Operator level are already Handled at
the Hook Level. So what's the point of duplicating it in Operator Level. Let me
take an example here
`Bigtable.py` operator file contains one class
`BigtableDeleteInstanceOperator` which has a method
```
` def execute(self, context: Context) -> None:
hook = BigtableHook(
gcp_conn_id=self.gcp_conn_id,
impersonation_chain=self.impersonation_chain,
)
try:
hook.delete_instance(project_id=self.project_id,
instance_id=self.instance_id)
except google.api_core.exceptions.NotFound:
self.log.info(
"The instance '%s' does not exist in project '%s'. Consider
it as deleted",
self.instance_id,
self.project_id,
)
except google.api_core.exceptions.GoogleAPICallError as e:
self.log.error("An error occurred. Exiting.")
raise e`
```
It raises exception when the instance does not exists which is already
handled at the Hook level see below
```
` @GoogleBaseHook.fallback_to_default_project_id
def delete_instance(self, instance_id: str, project_id: str) -> None:
instance = self.get_instance(instance_id=instance_id,
project_id=project_id)
if instance:
instance.delete()
else:
self.log.warning(
"The instance '%s' does not exist in project '%s'. Exiting",
instance_id, project_id
)`
```
Like wise the whole `Bigquery.py` has lot's of not necessary try/except
blocks.
### What you think should happen instead
_No response_
### How to reproduce
I will raise a PR for the above mentioned code first and in the next PR I
will fix the whole `Bigtable.py` file.
### Anything else
_No response_
### Are you willing to submit PR?
- [x] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
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]