BigQuery error 403 permission denied when i use "with" and "join" statements in query

Viewed 750

I'm working on a project with python3 and BigQuery and i encountered a strange behavior in google-cloud-bigquery library. When i exec simple query like:

select * from my.project where field1="foo" and field2="bar"

The program running well but when I try to use a more "complex" query like:

with a as (...),b as(...) select * from a as a_el select * from b as b_el join b_el on a_el.field1 = b_el.field1 ...

The program crash with:

google.api_core.exceptions.PermissionDenied: 403 request failed: the user does not have 'bigquery.readsession.create' permission

So, I know this is a permission problem but my question is: what's the difference under the hood? Why extra permission are needed? The tables are in the same project, so where is the problem?

I use query() method for execute queries

1 Answers

The google-cloud-bigquery python library leverages the BigQuery Storage read api to download query results faster. The permissions are part of the roles/bigquery.user predefined role. Likely you've got a custom role on the project that excludes the readsession permissions, which are permissions specific to the BigQuery storage API. This sounds like a case where the results from the first query are small enough that the storage API session doesn't get created.

More information about permissions can be found on the access control page.

Related