Skip to content

Move exception handling from Google Bigtable operators to hooks#61124

Merged
shahar1 merged 24 commits into
apache:mainfrom
KamranImaaz:new-remove-operators-redundant-exception-handling
Feb 10, 2026
Merged

Move exception handling from Google Bigtable operators to hooks#61124
shahar1 merged 24 commits into
apache:mainfrom
KamranImaaz:new-remove-operators-redundant-exception-handling

Conversation

@KamranImaaz

Copy link
Copy Markdown
Contributor

Fixes #60687

@KamranImaaz KamranImaaz requested a review from shahar1 as a code owner January 27, 2026 14:26
@boring-cyborg boring-cyborg Bot added area:providers provider:google Google (including GCP) related issues labels Jan 27, 2026
@KamranImaaz

Copy link
Copy Markdown
Contributor Author

@shahar1 due to a small mistake i accidentally pushed the all commits and got auto assigned reviewers. Sorry for that.

@shahar1 shahar1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not bad!
Please fix according to the comments.

Comment thread providers/google/src/airflow/providers/google/cloud/hooks/bigtable.py Outdated
@shahar1 shahar1 changed the title remove operators redundant exception handling Optimize exception handling in bigtable operator and hook Jan 27, 2026
@shahar1 shahar1 changed the title Optimize exception handling in bigtable operator and hook Optimize exception handling in GCP bigtable operator and hook Jan 27, 2026
@KamranImaaz

Copy link
Copy Markdown
Contributor Author

And Also Shahar this we are using everywhere in the operator instead of that we can use instance.exists() in one line in hooks right??

        instance = hook.get_instance(project_id=self.project_id, instance_id=self.instance_id)
        if not instance:
            raise AirflowException(f"Dependency: instance '{self.instance_id}' does not exist.")

@shahar1

shahar1 commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

instance = hook.get_instance(project_id=self.project_id, instance_id=self.instance_id)

You may encapsulate it in the hook where applicable

@KamranImaaz

Copy link
Copy Markdown
Contributor Author

Okay Sure

@KamranImaaz

Copy link
Copy Markdown
Contributor Author

I have updated the code according to your comments. Please have a view.

@KamranImaaz KamranImaaz requested a review from shahar1 January 28, 2026 20:51
@KamranImaaz

Copy link
Copy Markdown
Contributor Author

There are many open GCP issues(some are very older that i don't know whether they are relevant or not). If you don't mind can you assign me any of those issues. I would be happy to work on those.

Sounds good, please tag me in a couple of issues and I'll assign you if they are still relevant.

Sure I will tag you

@KamranImaaz

Copy link
Copy Markdown
Contributor Author

@shahar1 All Checks have passed!

@shahar1

shahar1 commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

@shahar1 All Checks have passed!

Great! I'll give Google's team a couple of more days to comment, and then I'll merge.

@KamranImaaz

KamranImaaz commented Feb 1, 2026

Copy link
Copy Markdown
Contributor Author

Shahar I have one suggestion. In Bigtable Hooks currently we are having this get_cluster_states_for_table (it fetches the clusters associated with a particular table) but which is currently not used by any Operator.

For BigtableCreateTableOperator, since clusters are created by default while creating a table, would it make sense to reuse this hook method and log the number (and possibly state) of clusters associated with the table after creation?

Whats your view in this??

@shahar1

shahar1 commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

get_cluster_states_for_table

Shahar I have one suggestion. In Bigtable Hooks currently we are having this get_cluster_states_for_table (it fetches the clusters associated with a particular table) but which is currently not used by any Operator.

For BigtableCreateTableOperator, since clusters are created by default while creating a table, would it make sense to reuse this hook method and log the number (and possibly state) of clusters associated with the table after creation?

Whats your view in this??

It's being used in the BigtableTableReplicationCompletedSensor sensor.
I don't think it makes sense to be used in BigtableCreateTableOperator, as clusters are not created by default (you run hook.get_instance() to get them, they are not auto-provisioned).

@shahar1

shahar1 commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

Following a recent incident - I want also to ensure that related system tests pass before merging this one.
@KamranImaaz - if you're able to run them, please go ahead and attach screenshots. Otherwise, we'll have to wait for either Google team or anyone else to run them.

CC: @VladaZakharova @KamranImaaz

@KamranImaaz

Copy link
Copy Markdown
Contributor Author

Following a recent incident - I want also to ensure that related system tests pass before merging this one. @KamranImaaz - if you're able to run them, please go ahead and attach screenshots. Otherwise, we'll have to wait for either Google team or anyone else to run them.

CC: @VladaZakharova @KamranImaaz

Hi @shahar1 while I currently do not have the access to run the system tests. I will try to get the access and run them. In the meanwhile google team can run them

@MaksYermak MaksYermak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shahar1

shahar1 commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

LGTM

Just to make it clear - are you ok with merging without running the system tests?
Personally I don't find anything that could be broken in the system tests due to the suggested changes, but it was @VladaZakharova 's request - so I want to ensure that we're all aligned.
If you are able to run it on your side before merging it would be the best, so we could avoid unnecessary reverts later on.
I'm also still waiting to chat with your team regarding the integration of Google provider system tests into the CI.
Thanks!

@shahar1

shahar1 commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

Ran it myself eventually, we're good to go:
image

@KamranImaaz - Great job!

@shahar1 shahar1 changed the title Optimize exception handling in GCP bigtable operator and hook Move exception handling from Google Bigtable operators to hooks Feb 10, 2026
@shahar1 shahar1 merged commit ca1640a into apache:main Feb 10, 2026
90 checks passed
@KamranImaaz

Copy link
Copy Markdown
Contributor Author

Thanks

@KamranImaaz KamranImaaz deleted the new-remove-operators-redundant-exception-handling branch February 10, 2026 16:19
Alok-kumar-priyadarshi pushed a commit to Alok-kumar-priyadarshi/airflow that referenced this pull request Feb 11, 2026
Ratasa143 pushed a commit to Ratasa143/airflow that referenced this pull request Feb 15, 2026
choo121600 pushed a commit to choo121600/airflow that referenced this pull request Feb 22, 2026
AkshayArali pushed a commit to AkshayArali/airflow_630 that referenced this pull request Feb 27, 2026
AkshayArali pushed a commit to AkshayArali/airflow_630 that referenced this pull request Feb 27, 2026
Subham-KRLX pushed a commit to Subham-KRLX/airflow that referenced this pull request Mar 4, 2026
dominikhei pushed a commit to dominikhei/airflow that referenced this pull request Mar 11, 2026
Ankurdeewan pushed a commit to Ankurdeewan/airflow that referenced this pull request Mar 15, 2026
radhwene pushed a commit to radhwene/airflow that referenced this pull request Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:google Google (including GCP) related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove redundant try/except blocks in airflow/providers/google/cloud/operators/bigtable.py

3 participants