DataflowJavaSDK icon indicating copy to clipboard operation
DataflowJavaSDK copied to clipboard

BigQueryIO need underlying "bigquery.tables.get permission" access to query a view

Open wli600 opened this issue 7 years ago • 11 comments

I am running a BigQueryIO like

BigQueryIO.Read.usingStandardSql().fromQuery("SELECT * FROM foo-bar-123456.category_view.markets LIMIT 1000")

but seeing this error, "The user [email protected] does not have bigquery.tables.get permission for table foo-bar-123456.category.markets"

which category is the base table for view category_view. And with perm opened for user [email protected] to the underlying table, this query works.

Also, without opening up the perm, when I run on console with the same query against the view, it works too

Can you help to take a look what might be the issue or maybe an usage error?

Thanks

PS. for the SDK version, I am running with the latest commit as of March 1,

commit c4bff0bc70a3d0d69f062d7f1e670a2e2b3fd05d Merge: fc5fee2 4a9f164 Author: Daniel Halperin [email protected] Date: Wed Mar 1 20:12:01 2017 -0800

wli600 avatar Mar 14 '17 17:03 wli600

@ThatRfernand could you please take a look?

aaltay avatar Mar 16 '17 17:03 aaltay

Hi wli600,

I believe you need to give this user ([email protected]) the right IAM permissions to interact with BigQuery. There is more information in https://cloud.google.com/bigquery/docs/access-control.

You can set the permissions via IAM in Cloud Console: https://console.cloud.google.com/iam-admin/iam/iam-zero. There is more information about IAM in https://cloud.google.com/iam/ .

Hope that helps!

ThatRfernand avatar Mar 16 '17 17:03 ThatRfernand

Thanks @ThatRfernand for looking at it,

The issue here is that this user does have perm to access the view, as I can use the user's account to query the view from console.

But running with the BigQuery against the view shows error message saying the account is lack of perm to access the table itself, but not the view, which is strange.

wli600 avatar Mar 16 '17 19:03 wli600

Further clarification: the view has been granted auth view access. So user has access to view, and view has access to underlying table. Query works fine via UI. Query fails via dataflow because it seems to be directly executing some metadata query directly against the underlying table.

criccomini avatar Mar 20 '17 19:03 criccomini

We're investigating this internally -- the key issue right now is a mismatch between what the BigQuery UI does and what Dataflow does. The BigQuery UI can get information via internal side channels that Dataflow cannot (since we only call public BigQuery APIs).

Will keep you updated.

dhalperi avatar Mar 23 '17 16:03 dhalperi

Any news on this @dhalperi?

bigquery.table.get enables the reading of table/view metadata - what table/view metadata does Dataflow need to read?

kennethmac2000 avatar Jul 13 '18 18:07 kennethmac2000

Yea, this is really annoying.

criccomini avatar Aug 25 '18 20:08 criccomini

Can you try using the withQueryLocation() property: https://github.com/apache/beam/blob/master/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java#L967

Currently we need extra permissions to determine the location of the query but if you set the above, extra permissions should not be required.

chamikaramj avatar Aug 29 '18 17:08 chamikaramj

Note that .withQueryLocation() was added to Apache Beam last April, so be sure to use Beam 2.5.0 or above.

ThatRfernand avatar Aug 29 '18 17:08 ThatRfernand

Access Denied: Table bigquery-public-data:san_francisco_bikeshare.bikeshare_trips: The user [email protected] does not have permission to query table bigquery-public-data:san_francisco_bikeshare.bikeshare_trips.

IAM permissions: pinchepoutine.com.mx BigQuery Admin BigQuery Job User BigQuery User Billing Account Creator Owner Project Creator

[email protected] BigQuery Admin BigQuery Job User BigQuery User Organization Administrator

xpat avatar Jan 05 '19 00:01 xpat

I had the same issue and solved adding these permissions to the service account used by the compute engine that runs the dataflow job

Oliveirakun avatar Mar 01 '21 20:03 Oliveirakun