Reputation: 980
I'm using the Go client for Bigquery with our setup located (as far as I can tell) entirely in the EU location, but I see some errors stating
Access Denied: Table <table>: User does not have permission to query table <table>, or perhaps it does not exist in location US
My understanding is that if my dataset and tables are in EU, the jobs will also be run there. However, I can see in the log details that the job is labeled as using the US location:
resource: {
labels: {
location: "US"
project_id: "<project_id>"
}
type: "bigquery_project"
}
The CloudRun instance this is running from is also in the EU, specifically europe-west6
.
Not sure how to fix this.
Per comment from guillaume blaquiere, here's a rough approximation of the code:
client, err := bigquery.NewClient(ctx, 'my-project')
if err != nil {
return false, err
}
checkQuery := fmt.Sprintf(`
SELECT COUNT(*) AS Count
FROM %s
WHERE Id = @id`,
'tableName',
)
q := client.Query(checkQuery)
q.Parameters = []bigquery.QueryParameter{
{
Name: "id",
Value: id,
},
})
type check struct {
Count int64
}
var check flightCheck
it, err := q.Read(ctx)
if err != nil {
return false, err
}
if err := it.Next(result); err != nil {
s.log.Error(err, "failed to get query result")
return false, err
}
return check > 0, nil
Upvotes: 0
Views: 9615
Reputation: 980
Turns out I had something going on with how my project name was being generated via code, where my environment was being appended twice, so project-dev
became project-dev-dev
, which I missed in the error message. So I was missing that the table name was project-dev-dev.dataset.table
instead of project-dev.dataset.table
. 🤦♂️
tl;dr Make sure your project name is correct.
Upvotes: 2
Reputation: 974
try setting the location q.Location = "EU"
. (If it's multi-region in EU you can use EU
or you need to find out the exact region and use something like europe-west2
Upvotes: 0