Skip to content

Commit

Permalink
add clarifying faq and info on permissions
Browse files Browse the repository at this point in the history
this pr adds a couple of sentences clarifying users need the right permission/access to create schemas when running store_failures config. 

raised in slack thread by @wusanny : https://dbt-labs.slack.com/archives/C02NCQ9483C/p1721798716164609
  • Loading branch information
mirnawong1 authored Jul 24, 2024
1 parent fd009ad commit e44e78b
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions website/docs/reference/resource-configs/store_failures.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ Optionally set a test to always or never store its failures in the database.
- If the `store_failures` config is `none` or omitted, the resource will use the value of the `--store-failures` flag.
- When true, `store_failures` saves all the record(s) that failed the test only if [limit](/reference/resource-configs/limit) is not set or if there are fewer records than the limit. `store_failures` are saved in a new table with the name of the test.
- A test's results will always **replace** previous failures for the same test, even if that test results in no failures.
- By default, `store_failures` uses a schema named `dbt_test__audit`, but, you can [configure](/reference/resource-configs/schema#tests) the schema to a different value.
- By default, `store_failures` uses a schema named `dbt_test__audit`, but, you can [configure](/reference/resource-configs/schema#tests) the schema to a different value.
- **Note**: Ensure you have the authorization to create or access schemas for your work. To ensure that the required schemas have the correct permissions, run a sql statement in your data platform environment. For example, run the following command if using Redshift:

This logic is encoded in the [`should_store_failures()`](https://github.com/dbt-labs/dbt-adapters/blob/60005a0a2bd33b61cb65a591bc1604b1b3fd25d5/dbt/include/global_project/macros/materializations/configs.sql#L15) macro.
```sql
create schema if not exists dev_username_dbt_test__audit authorization username;
```
_Replace `dev_username` with your specific development schema name and `username` with the appropriate user who should have the permissions._

This command grants the appropriate permissions to create and access the `dbt_test__audit` schema, which is often used with the `store_failures` configuration.

This logic is encoded in the [`should_store_failures()`](https://github.com/dbt-labs/dbt-adapters/blob/60005a0a2bd33b61cb65a591bc1604b1b3fd25d5/dbt/include/global_project/macros/materializations/configs.sql#L15) macro.


<Tabs
Expand Down Expand Up @@ -110,3 +116,20 @@ tests:
</TabItem>
</Tabs>
## FAQs
<detailsToggle alt_header="Receiving a 'permissions denied for schema' error"
If you're receiving a `Adapter name adapter: Adapter_name error: permission denied for schema dev_usernamea_dbt_test__audit`, this is most likely due to your user not having permission to create new schemas, despite having owner access to your own development schema.

To resolve this, you need proper authorization to create or access custom schemas. Run the following SQL command in the data platform environment:

```sql
create schema if not exists dev_username_dbt_test__audit authorization username;
```
_Replace `dev_username` with your specific development schema name and `username` with the appropriate user who should have the permissions._

This command grants the appropriate permissions to create and access the dbt_test__audit schema, which is often used with the store_failures configuration.

</detailsToggle>

0 comments on commit e44e78b

Please sign in to comment.