Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expanding access to configs #4146

Merged
merged 10 commits into from
Oct 11, 2023
4 changes: 2 additions & 2 deletions website/docs/docs/build/groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This functionality is new in v1.5.

## About groups

A group is a collection of nodes within a dbt DAG. Groups are named, and every group has an `owner`. They enable intentional collaboration within and across teams by restricting [access to private](/reference/resource-properties/access) models.
A group is a collection of nodes within a dbt DAG. Groups are named, and every group has an `owner`. They enable intentional collaboration within and across teams by restricting [access to private](/reference/resource-configs/access) models.

Group members may include models, tests, seeds, snapshots, analyses, and metrics. (Not included: sources and exposures.) Each node may belong to only one group.

Expand Down Expand Up @@ -94,7 +94,7 @@ select ...

### Referencing a model in a group

By default, all models within a group have the `protected` [access modifier](/reference/resource-properties/access). This means they can be referenced by downstream resources in _any_ group in the same project, using the [`ref`](/reference/dbt-jinja-functions/ref) function. If a grouped model's `access` property is set to `private`, only resources within its group can reference it.
By default, all models within a group have the `protected` [access modifier](/reference/resource-configs/access). This means they can be referenced by downstream resources in _any_ group in the same project, using the [`ref`](/reference/dbt-jinja-functions/ref) function. If a grouped model's `access` property is set to `private`, only resources within its group can reference it.

<File name='models/schema.yml'>

Expand Down
2 changes: 1 addition & 1 deletion website/docs/docs/collaborate/govern/model-access.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The two concepts will be closely related, as we develop multi-project collaborat

## Related documentation
* [`groups`](/docs/build/groups)
* [`access`](/reference/resource-properties/access)
* [`access`](/reference/resource-configs/access)

## Groups

Expand Down
4 changes: 2 additions & 2 deletions website/docs/reference/model-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ models:
show: true | false
[latest_version](/reference/resource-properties/latest_version): <version_identifier>
[deprecation_date](/reference/resource-properties/deprecation_date): <YAML_DateTime>
[access](/reference/resource-properties/access): private | protected | public
[access](/reference/resource-configs/access): private | protected | public
[config](/reference/resource-properties/config):
[<model_config>](/reference/model-configs): <config_value>
[constraints](/reference/resource-properties/constraints):
Expand Down Expand Up @@ -46,7 +46,7 @@ models:
[description](/reference/resource-properties/description): <markdown_string>
[docs](/reference/resource-configs/docs):
show: true | false
[access](/reference/resource-properties/access): private | protected | public
[access](/reference/resource-configs/access): private | protected | public
[constraints](/reference/resource-properties/constraints):
- <constraint>
[config](/reference/resource-properties/config):
Expand Down
2 changes: 1 addition & 1 deletion website/docs/reference/node-selection/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ Supported in v1.5 or newer.

<VersionBlock firstVersion="1.5">

The `access` method selects models based on their [access](/reference/resource-properties/access) property.
The `access` method selects models based on their [access](/reference/resource-configs/access) property.

```bash
dbt list --select access:public # list all public models
Expand Down
97 changes: 97 additions & 0 deletions website/docs/reference/resource-configs/access.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
resource_types: [models]
datatype: access
---

<File name='models/<schema>.yml'>

```yml
version: 2

models:
- name: model_name
access: private | protected | public
```

</File>

<VersionBlock lastVersion="1.6">

Access modifiers may be applied to models one-by-one in YAML properties. In v1.5 and v1.6, you are unable to configure `access` for multiple models at once. Upgrade to v1.7 for additional configuration options. A group or subfolder contains models with varying access levels, so when you designate a model with `access: public`, make sure you intend for this behavior.

</VersionBlock>

<VersionBlock firstVersion="1.7">

You can apply access modifiers in config files, including `the dbt_project.yml`, or to models one-by-one in YAML properties. Applying access configs to a subfolder modifies the default for all models in that subfolder, so make sure you intend for this behavior. When setting individual model access, a group or subfolder might contain a variety of access levels, so when you designate a model with `access: public` make sure you intend for this behavior.

There are multiple approaches to configuring access:

In the model configs of `dbt_project.yml``:

```yaml
models:
- name: my_public_model
access: public # Older method, still supported

```
Or (but not both)

```yaml
models:
- name: my_public_model
config:
access: public # newly supported in v1.7

```

In a subfolder:
```yaml
models:
my_project_name:
subfolder_name:
+group: <my_group>
+access: private # sets default for all models in this subfolder
```

In the model.sql file:

```sql
-- models/my_public_model.sql

{{ config(access = "public") }}

select ...
```

</VersionBlock>

## Definition
The access level of the model you are declaring properties for.

Some models (not all) are designed to be referenced through the [ref](/reference/dbt-jinja-functions/ref) function across [groups](/docs/build/groups).

| Access | Referenceable by |
|-----------|-------------------------------|
| private | same group |
| protected | same project/package |
| public | any group, package or project |

If you try to reference a model outside of its supported access, you will see an error:

```shell
dbt run -s marketing_model
...
dbt.exceptions.DbtReferenceError: Parsing Error
Node model.jaffle_shop.marketing_model attempted to reference node model.jaffle_shop.finance_model,
which is not allowed because the referenced node is private to the finance group.
```

## Default

By default, all models are "protected." This means that other models in the same project can reference them.

## Related docs

* [Model Access](/docs/collaborate/govern/model-access#groups)
* [Group configuration](/reference/resource-configs/group)
53 changes: 0 additions & 53 deletions website/docs/reference/resource-properties/access.md

This file was deleted.

2 changes: 1 addition & 1 deletion website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,6 @@ const sidebarSettings = {
type: "category",
label: "General properties",
items: [
"reference/resource-properties/access",
"reference/resource-properties/columns",
"reference/resource-properties/config",
"reference/resource-properties/constraints",
Expand All @@ -659,6 +658,7 @@ const sidebarSettings = {
type: "category",
label: "General configs",
items: [
"reference/resource-configs/access",
"reference/resource-configs/alias",
"reference/resource-configs/database",
"reference/resource-configs/enabled",
Expand Down
5 changes: 5 additions & 0 deletions website/vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -4001,6 +4001,11 @@
"source": "/docs/dbt-cloud/on-premises/upgrading-kots",
"destination": "/docs/deploy/single-tenant",
"permanent": true
},
{
"source": "/reference/resource-properties/access",
"destination": "/reference/resource-configs/access",
"permanent": true
}
]
}
Loading