You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Errors occur when referencing multiple databases or Snowflake databases.
To Reproduce
Steps to reproduce the behavior:
Create multiple databases and use them in dbt.
Execute dbt run-operation create_elementary_user
Expected behavior
Generated SQL can be executed.
Additional context
SQL that is actually generated and causes problems
-- Information schema access
CREATE OR REPLACE PROCEDURE ELEMENTARY_GRANT_INFO_SCHEMA_ACCESS(database_name STRING, role_name STRING)
RETURNS VARCHAR
LANGUAGE SQL
AS
$$
BEGINGRANT USAGE,MONITOR ON DATABASE IDENTIFIER(:database_name) TO ROLE IDENTIFIER(:role_name);
GRANT USAGE,MONITOR ON ALL SCHEMAS IN DATABASE PREP TO ROLE IDENTIFIER(:role_name);
GRANT USAGE,MONITOR ON FUTURE SCHEMAS IN DATABASE PREP TO ROLE identifier(:role_name);
GRANTREFERENCESON ALL TABLES IN DATABASE IDENTIFIER(:database_name) TO ROLE IDENTIFIER(:role_name);
GRANTREFERENCESON ALL VIEWS IN DATABASE IDENTIFIER(:database_name) TO ROLE IDENTIFIER(:role_name);
GRANTREFERENCESON ALL EXTERNAL TABLES IN DATABASE IDENTIFIER(:database_name) TO ROLE IDENTIFIER(:role_name);
GRANTREFERENCESON FUTURE TABLES IN DATABASE IDENTIFIER(:database_name) TO ROLE IDENTIFIER(:role_name);
GRANTREFERENCESON FUTURE VIEWS IN DATABASE IDENTIFIER(:database_name) TO ROLE IDENTIFIER(:role_name);
GRANTREFERENCESON FUTURE EXTERNAL TABLES IN DATABASE IDENTIFIER(:database_name) TO ROLE IDENTIFIER(:role_name);
END;
$$
;
CALL ELEMENTARY_GRANT_INFO_SCHEMA_ACCESS('snowflake', $elementary_role);
CALL ELEMENTARY_GRANT_INFO_SCHEMA_ACCESS('RAW', $elementary_role);
CALL ELEMENTARY_GRANT_INFO_SCHEMA_ACCESS('ELEMENTARY', $elementary_role);
CALL ELEMENTARY_GRANT_INFO_SCHEMA_ACCESS('PROD', $elementary_role);
CALL ELEMENTARY_GRANT_INFO_SCHEMA_ACCESS('PREP', $elementary_role);
Want
The snowflake database is a special database, so if you try to grant it, you will get an error, which you want to ignore.
In an environment where multiple databases are being operated, grant to {{database}} will be insufficient, so we want to use the database of the argument.
The text was updated successfully, but these errors were encountered:
Describe the bug
Errors occur when referencing multiple databases or Snowflake databases.
To Reproduce
Steps to reproduce the behavior:
dbt run-operation create_elementary_user
Expected behavior
Generated SQL can be executed.
Additional context
SQL that is actually generated and causes problems
Want
The text was updated successfully, but these errors were encountered: