user2846616
user2846616

Reputation: 31

Join BigQuery tables in different projects using Service Accounts

I have service accounts per BigQuery project. I need to put joins on tables in different projects using service accounts configured on each project.

Here is what i have:

  1. Service_EmailAccount1 -> project1
  2. Service_EmailAccount2 -> project2

I can connect to tables using these service accounts in respective projects but when I try to join data on different tables which are in different projects, I get access errors.

Reason is when i build the BigQuery service , I am using a JSON file which is specific to project as it contains the project id.

How can I join tables in different projects using service accounts?

Upvotes: 0

Views: 2687

Answers (2)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172944

Assuming you run your query by Service_EmailAccount1
In this case you should just share your respective dataset in project2 with Service_EmailAccount1
And you must make sure both datasets are in the same location
That's all you need

See more about Access Control concept in BigQuery

Upvotes: 2

Haipeng Su
Haipeng Su

Reputation: 2541

I believe that the following idea might be helpful, for example, you are using service_emailaccount1 to get access of project1,

  1. go to bigquery, click the project name, then choose -> switch project -> manage projects, you will go to IAm & Admin page
  2. choose project1 and then you will see the permission page for the project.
  3. add service_emalaccount2 to be a viewer/editor to this project1(if account1 is the owner)

Then, I believe that both accounts will access project1.
This is what I will do to get access to several projects, and I am not sure we can use different service account to querying from different project in one query. Thx

Upvotes: 1

Related Questions