I need to import from the view that is in one project when inside view there are joins to tables from other project.
import pandas as pd
from google.cloud import bigquery
from google.oauth2 import service_account
#----------BigQuery Connect---------------
cred_1 = service_account.Credentials.from_service_account_file(filename="project1.json")
cred_2 = service_account.Credentials.from_service_account_file(filename="project2.json")
client = bigquery.Client(credentials=cred_1, project=cred.project_id)
medicare = client.dataset('dataset', project='project1')
# --------- from Bigquery-----------------------------------
statment = """select * FROM `project1.dataset.view`"""
query_job = client.query(statment )
result = query_job.result()
df = result.to_dataframe()
df.head()
Since there is in the view the use of tables from another project, I get an error:
Forbidden: 403 Access Denied: Table project2:dataset.table: User does not have permission to query table project2:dataset.table.
I have two JSON files with credentials to two projects, but it's not clear how to combine them to give access to two projects.
How can such a problem be solved?