Skip to content

Commit

Permalink
updates to resource path (#4394)
Browse files Browse the repository at this point in the history
PR clarifies how to disable sources and addresses core issue
dbt-labs/dbt-core#8960 and adds the resource
paths page to the sidebar.

This also Resolves #4313
  • Loading branch information
mirnawong1 authored Nov 7, 2023
2 parents bc7d4a2 + 02f9615 commit b506c6c
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 5 deletions.
47 changes: 43 additions & 4 deletions website/docs/reference/resource-configs/resource-path.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
The `<resource-path>` nomenclature is used in this documentation when documenting how to configure a model, seed, or snapshot, from your `dbt_project.yml` file. It represents the nested dictionary keys that provide the path to either a directory of models, or a single model.
---
title: Resource path
description: "Learn how to use resource paths to configure resource types in dbt."
id: resource-path
sidebar_label: "About resource paths"
---

The `<resource-path>` nomenclature is used in this documentation when documenting how to configure resource types like models, seeds, snapshots, tests, sources, and others, from your `dbt_project.yml` file.

It represents the nested dictionary keys that provide the path to a directory of that resource type, or a single instance of that resource type by name.

```yml
resource_type:
project_name:
directory_name:
subdirectory_name:
instance_of_resource_type (by name):
...
```
## Example
:::info
This example is for models, but the same concepts apply for seeds and snapshots.
The following examples are mostly for models and a source, but the same concepts apply for seeds, snapshots, tests, sources, and other resource types.
:::
### Apply config to all models
To apply a configuration to all models, do not use a `<resource-path>`:

Expand All @@ -18,6 +35,8 @@ models:

</File>

### Apply config to all models in your project

To apply a configuration to all models in _your_ project only, use your [project name](/reference/project-configs/name) as the `<resource-path>`:

<File name='dbt_project.yml'>
Expand All @@ -32,6 +51,8 @@ models:

</File>

### Apply config to all models in a subdirectory

To apply a configuration to all models in a subdirectory of your project, e.g. `staging`, nest the directory under the project name:

<File name='dbt_project.yml'>
Expand All @@ -57,6 +78,8 @@ In the following project, this would apply to models in the `staging/` directory
```

### Apply config to all models in one model

To apply a configuration to one model, nest the full path under the project name. For a model at `/staging/stripe/payments.sql`, this would look like:

<File name='dbt_project.yml'>
Expand Down Expand Up @@ -92,3 +115,19 @@ In the following project, this would only apply to the `payments` model:
   └── payments.sql

```
### Apply config source nested in a subfolder
To disable a source nested in a YAML file in a subfolder, you will need to supply the path to that YAML file, as well as the source name in the `dbt_project.yml` file.<br /><br />
The following example shows how to disable a source nested in a YAML file in a subfolder:
<File name='dbt_project.yml'>
```yaml
sources:
your_project_name:
subdirectory_name:
source_yaml_file_name:
source_name:
+enabled: false # This will apply to sources nested in subfolders.
```
</File>
19 changes: 18 additions & 1 deletion website/docs/reference/source-configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,24 @@ sources:

## Configuring sources

Sources can be configured via a `config:` block within their `.yml` definitions, or from the `dbt_project.yml` file under the `sources:` key. This configuration is most useful for configuring sources imported from [a package](/docs/build/packages). You can disable sources imported from a package to prevent them from rendering in the documentation, or to prevent [source freshness checks](/docs/build/sources#snapshotting-source-data-freshness) from running on source tables imported from packages.
Sources can be configured via a `config:` block within their `.yml` definitions, or from the `dbt_project.yml` file under the `sources:` key. This configuration is most useful for configuring sources imported from [a package](/docs/build/packages).

You can disable sources imported from a package to prevent them from rendering in the documentation, or to prevent [source freshness checks](/docs/build/sources#snapshotting-source-data-freshness) from running on source tables imported from packages.

- **Note**: To disable a source nested in a YAML file in a subfolder, you will need to supply the path to that YAML file plus the source name in the dbt_project.yml file. For example:

<File name='dbt_project.yml'>

```yml
sources:
your_project_name:
subdirectory_name:
source_yaml_file_name:
source_name:
+enabled: false # This will apply to sources nested in subfolders.
```
</File>
### Examples
Expand Down
1 change: 1 addition & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ const sidebarSettings = {
label: "Resource configs and properties",
items: [
"reference/configs-and-properties",
"reference/resource-configs/resource-path",
{
type: "category",
label: "General properties",
Expand Down

0 comments on commit b506c6c

Please sign in to comment.