6
votes

I have access to a BigQuery table and I can use it from BigQuery console or gcloud command line. But I am unable to write basic queries against it in Datalab and get an access denied error.

2

2 Answers

4
votes

Datalab is intended for use in a team environment. Notebooks may contain results of code execution (e.g. a BigQuery SQL query) and are accessible to members of the project. Hence, Datalab uses the App Engine service account in your project to access data. This ensures uniform access for viewing and executing notebooks and minimizes the risk of accidental disclosure of data. If you do not control access to data, you may need to ask that access be granted to the service account. You can find the service account in the Developers Console by clicking Permissions in the left navigation bar and locating the App Engine service account. Currently, Datalab does not use individual user's credentials.

0
votes

Was it the same project that you worked in from BigQuery Console and in Datalab? If yes, you need to be the project owner/editor permission.

Also, please notice that in Google Datalab, the notebook is using a service account to get access to data, instead of your own account. So you can check if there's any permission differences between these two accounts. For example, if in your queries, you were referring to data set in another BigQuery project, you can do these steps:

  1. run the following command in your datalab notebook to check which service account is being used:

    %%bash curl --silent -H "Metadata-Flavor: Google" \ http://metadata/computeMetadata/v1/instance/service-accounts/default/email

  2. add the service account shown as the result of step 1 to the permission list of the other projects that are being queried