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

6715 improve documentation for dbt clean options #6719

Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@
- **[Breaking change detection](/reference/resource-properties/versions#detecting-breaking-changes) for models with contracts enforced:** When dbt detects a breaking change to a model with an enforced contract during state comparison, it will now raise an error for versioned models and a warning for models that are not versioned.
- **[Set `access` as a config](/reference/resource-configs/access):** You can now set a model's `access` within config blocks in the model's file or in the `dbt_project.yml` for an entire subfolder at once.
- **[Type aliasing for model contracts](/reference/resource-configs/contract):** dbt will use each adapter's built-in type aliasing for user-provided data types—meaning you can now write `string` always, and dbt will translate to `text` on Postgres/Redshift. This is "on" by default, but you can opt-out.
- **[Raise warning for numeric types](/reference/resource-configs/contract):** Because of issues when putting `numeric` in model contracts without considering that default values such as `numeric(38,0)` might round decimals accordingly. dbt will now warn you if it finds a numeric type without specified precision/scale.
- **[Raise warning for numeric types](/reference/resource-configs/contract):** Because of issues when putting `numeric` in model contracts without considering that default values such as `numeric(38,0)` might round decimals accordingly. dbt will now warn you if it finds a numeric type without specified precision/scale.

### dbt clean

Starting in v1.7, `dbt clean` will only clean paths within the current working directory. The `--no-clean-project-files-only` flag will delete all paths specified in the `clean-targets` section of `dbt_project.yml`, even if they're outside the dbt project.
Starting in v1.7, [dbt clean](/reference/commands/clean) will only clean paths within the current working directory. The `--no-clean-project-files-only` flag will delete all paths specified in the `clean-targets` section of `dbt_project.yml`, even if they're outside the dbt project.

Check warning on line 69 in website/docs/docs/dbt-versions/core-upgrade/08-upgrading-to-v1.7.md

View workflow job for this annotation

GitHub Actions / Vale linting

[vale] reported by reviewdog 🐶 [custom.Typos] Oops there's a typo -- did you really mean 'v1.7'? Raw Output: {"message": "[custom.Typos] Oops there's a typo -- did you really mean 'v1.7'? ", "location": {"path": "website/docs/docs/dbt-versions/core-upgrade/08-upgrading-to-v1.7.md", "range": {"start": {"line": 69, "column": 13}}}, "severity": "WARNING"}
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved

Supported flags:
- `--clean-project-files-only` (default)
Expand Down
41 changes: 40 additions & 1 deletion website/docs/reference/commands/clean.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,45 @@
id: "clean"
---

`dbt clean` is a utility function that deletes all folders specified in the [`clean-targets`](/reference/project-configs/clean-targets) list specified in `dbt_project.yml`. You can use this to delete the `dbt_packages` and `target` directories.
`dbt clean` is a utility function that deletes the paths specified within the [`clean-targets`](/reference/project-configs/clean-targets) list in the `dbt_project.yml` file. It helps by removing unnecessary files or directories generated during the execution of other dbt commands, ensuring a clean state for the project.

## Example usage
```
dbt clean
```

## Supported flags
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved

This section will briefly explain the following flags:

- [`--clean-project-files-only`](#--clean-project-files-only) (default)
- [`--no-clean-project-files-only`](#--no-clean-project-files-only)

To view the list of all supported flags for the `dbt clean` command in the terminal, use the `--help` flag, which will display detailed information about the available flags you can use, including its description and usage:

```shell
dbt clean --help
```

### --clean-project-files-only (default)

Check warning on line 27 in website/docs/reference/commands/clean.md

View workflow job for this annotation

GitHub Actions / Vale linting

[vale] reported by reviewdog 🐶 [custom.SentenceCaseHeaders] '--clean-project-files-only (default)' should use sentence-style capitalization. Try 'Clean project files only default' instead. Raw Output: {"message": "[custom.SentenceCaseHeaders] '--clean-project-files-only (default)' should use sentence-style capitalization. Try 'Clean project files only default' instead.", "location": {"path": "website/docs/reference/commands/clean.md", "range": {"start": {"line": 27, "column": 5}}}, "severity": "WARNING"}
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved
By default, dbt deletes all the paths within the project directory specified in `clean-targets`.

:::note
Avoid using paths outside the dbt project; otherwise, you will see an error.
:::


#### Example usage
```shell
dbt clean --clean-project-files-only
```

### --no-clean-project-files-only

Check warning on line 40 in website/docs/reference/commands/clean.md

View workflow job for this annotation

GitHub Actions / Vale linting

[vale] reported by reviewdog 🐶 [custom.SentenceCaseHeaders] '--no-clean-project-files-only' should use sentence-style capitalization. Try 'No clean project files only' instead. Raw Output: {"message": "[custom.SentenceCaseHeaders] '--no-clean-project-files-only' should use sentence-style capitalization. Try 'No clean project files only' instead.", "location": {"path": "website/docs/reference/commands/clean.md", "range": {"start": {"line": 40, "column": 5}}}, "severity": "WARNING"}
Deletes all the paths specified in the `clean-targets` list of `dbt_project.yml`, including those outside the current dbt project.

```shell
dbt clean --no-clean-project-files-only
```

## dbt clean with remote file system
To avoid complex permissions issues and potentially deleting crucial aspects of the remote file system without access to fix them, this command does not work when interfacing with the RPC server that powers the dbt Cloud IDE. Instead, when working in dbt Cloud, the `dbt deps` command cleans before it installs packages automatically. The `target` folder can be manually deleted from the sidebar file tree if needed.
Loading