BigQuery UI查询表,但AI笔记本抱怨权限问题



我有两个项目。Project Apple在BQ表中有数据。Project Banana已经读取了苹果BQ表的访问权限。当我使用Banana的BQ UI运行查询时,一切都很好。同样的查询在Banana的AI笔记本上不起作用。

Banana BQ UI:

AVG(A) as A_mean_exact,
APPROX_QUANTILES(A, 100)[OFFSET(50)] AS A_percentile_50_approx,
APPROX_QUANTILES(A, 100)[OFFSET(90)] AS A_percentile_90_approx
FROM `apple.v1003.apple_table`
WHERE selected_run = 1

工作良好。

Banana的AI笔记本:

from google.cloud import bigquery
client = bigquery.Client(location="US", project="banana") # I also tried apple; same error
print("Client creating using default project: {}".format(client.project)) 

Client creating using default project: banana

query = """
SELECT 
AVG(A) as A_mean_exact,
APPROX_QUANTILES(A, 100)[OFFSET(50)] AS A_percentile_50_approx,
APPROX_QUANTILES(A, 100)[OFFSET(90)] AS A_percentile_90_approx
FROM `apple.v1003.apple_table`
WHERE selected_run = 1
"""
query_job = client.query(
query,
location="US",
) 
df = query_job.to_dataframe()
df
Forbidden: 403 Access Denied: Table apple:v1003.apple_table: User does not have permission to query table apple:v1003.apple_table.

你能建议我应该调查什么吗?我刚开始使用AI Hub。

您当前已授予项目帐户的权限,但笔记本正试图通过与运行JupyterLab的计算引擎实例关联的服务帐户访问BigQuery。

您必须转到计算Egnine>您的笔记本电脑>查看网络详细信息>并查看它使用的服务帐户(在Banana中(。然后,在Apple的项目IAM部分中授予该帐户的权限。

最新更新