run_grant_dataset_view_access fails if view already exists #35795
Labels
area:providers
good first issue
kind:bug
This is a clearly a bug
provider:google
Google (including GCP) related issues
Apache Airflow version
Other Airflow 2 version (please specify below)
What happened
The function run_grant_dataset_view_access does not correctly check if the view already exists, breaking what's specified in the docs
What you think should happen instead
The function should skip trying to create the view if it already exists
How to reproduce
Use GCP Composer, create a DAG with a BigQueryHook, call run_grant_dataset_view_access to grant a view in dataset A access to dataset B, but the view already has access to dataset B.
Operating System
composer-2.5.1-airflow-2.6.3
Versions of Apache Airflow Providers
The ones included in the above installation (the provider in question is google-cloud-bigquery==3.12.0)
Deployment
Google Cloud Composer
Deployment details
No response
Anything else
Investigation:
The logs include "Granting table xxx authorized view access to xxx dataset.", which indicates that this if-statement is True.
When running a python script locally with the same version of google-cloud-bigquery I found that the AccessEntry object fetched from the dataset does not match the created AccessEntry object. The mismatch occurs in the _properties dict, where the fetched AccessEntry only contains one entry view whereas the created one contains two entries, view and role. The following script shows the problem
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: