Search code examples
google-bigquery

I keep getting Access Denied error in GCP bigQuery


Any time i run this query

SELECT country_name, year, value 
FROM `bigquery- publicdata.world_bank_wdi.indicators_data` as WB_WDI 
WHERE indicator_name = 'Population, total' 
AND year = 2016

I keep getting this error bellow.

Access Denied: Table bigquery-publicdata:world_bank_wdi.indicators_data: User does not have permission to query table bigquery-publicdata:world_bank_wdi.indicators_data, or perhaps it does not exist.

This is a public database, and I looked to make sure the table existed. I am not sure why I am getting the error. Can anybody help?


Solution

  • works fine with the correct dataset identifier:

    SELECT country_name, year, value 
     FROM `bigquery-public-data.world_bank_wdi.indicators_data` as WB_WDI
     WHERE  indicator_name = 'Population, total' 
    AND year = 2016
    

    output

    Row country_name year value
    
    1 Namibia 2016 2358044.0 2  
    
    2 Kyrgyz Republic 2016 6079500.0 3  
    
    ...
    

    To determine the correct dataset identifier, type bigquery-public-data into the BigQuery web console's explorer search box and hit enter. Datasets within the public data collection will then be listed. You can drill down to see the table formats, and even create a template sql query to fill in manually. Best practice is to always prefer the copy/paste commands to move these identifiers or queries over manual retyping. Manual retyping, handwritten notes, etc., can introduce errors.