Cannot connect to Snowflake Database from Cloud dbt IDE

Issue

I have trouble replicating Step 7 of ’ Quickstart for dbt Cloud and Snowflake’. I tried to create the customers model but my dbt run failed. Error is ‘Database ‘RAW’ does not exist or not authorized’.’

Update 8/5/2024

After I granted permissions specifically to ‘PC_dbt_ROLE’ in snowflake ‘RAW’ database, the error message has changed to 'Object ‘RAW.JAFFLE_SHOP.CUSTOMERS’ does not exist or not authorized. I assume that means I now have access to RAW db and JAFFLE_SHOP schema but no access to the customers table.

Other Details

The role in my project setting is PC_dbt_ROLE, and ‘session keep live’ is unchecked. Not sure what I have missed.

Some example code or error messages

18:42:02 Began running node model.my_new_project.customers
18:42:02 1 of 3 START sql view model dbt_XXie.customers ................................. [RUN]
18:42:02 Began compiling node model.my_new_project.customers
18:42:02 Writing injected SQL for node "model.my_new_project.customers"
18:42:02 Began executing node model.my_new_project.customers
18:42:02 Writing runtime sql for node "model.my_new_project.customers"
18:42:02 Using snowflake connection "model.my_new_project.customers"
18:42:02 On model.my_new_project.customers: /* {"app": "dbt", "dbt_version": "2024.8.221", "profile_name": "user", "target_name": "default", "node_id": "model.my_new_project.customers"} */
create or replace   view PC_DBT_DB.dbt_XXie.customers
  
   as (
    with customers as (

    select
        id as customer_id,
        first_name,
        last_name

    from raw.jaffle_shop.customers

),

orders as (

    select
        id as order_id,
        user_id as customer_id,
        order_date,
        status

    from raw.jaffle_shop.orders

),

customer_orders as (

    select
        customer_id,

        min(order_date) as first_order_date,
        max(order_date) as most_recent_order_date,
        count(order_id) as number_of_orders

    from orders

    group by 1

),

final as (

    select
        customers.customer_id,
        customers.first_name,
        customers.last_name,
        customer_orders.first_order_date,
        customer_orders.most_recent_order_date,
        coalesce(customer_orders.number_of_orders, 0) as number_of_orders

    from customers

    left join customer_orders using (customer_id)

)

select * from final
  );
18:42:02 Opening a new connection, currently in state closed
18:42:02 Snowflake adapter: Snowflake query id: 01b626e2-0306-d23a-0000-0007caebc23d
18:42:02 Snowflake adapter: Snowflake error: 002003 (02000): 01b626e2-0306-d23a-0000-0007caebc23d: SQL compilation error:
Database 'RAW' does not exist or not authorized.
18:42:02 On model.my_new_project.customers: Close
18:42:02 Database Error in model customers (models/customers.sql)
  002003 (02000): 01b626e2-0306-d23a-0000-0007caebc23d: SQL compilation error:
  Database 'RAW' does not exist or not authorized.
  compiled Code at target/run/my_new_project/models/customers.sql
18:42:02 1 of 3 ERROR creating sql view model dbt_XXie.customers ........................ [e[31mERRORe[0m in 0.30s]
18:42:02 Finished running node model.my_new_project.customers
18:42:04   Database Error in model customers (models/customers.sql)
  002003 (02000): 01b626e2-0306-d23a-0000-0007caebc23d: SQL compilation error:
  Database 'RAW' does not exist or not authorized.
  compiled Code at target/run/my_new_project/models/customers.sql

I solved this issue by granting USAGE permission to all databases and schemas that my model uses and SELECT permission to my tables.

tried this but didn’t worked