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

Update linter docs for dbt Cloud CLI #5753

Merged
merged 13 commits into from
Jul 16, 2024
31 changes: 24 additions & 7 deletions website/docs/docs/cloud/configure-cloud-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,34 @@ As a tip, most command-line tools have a `--help` flag to show available command
- `dbt run --help`: Lists the flags available for the `run` command
:::

### SQLFluff integration
The dbt Cloud CLI supports [SQLFluff](https://sqlfluff.com/), a modular and configuration SQL linter, which warns you of complex functions, syntax, formatting, and compilation errors.
### Lint SQL files

To get started, run `dbt sqlfluff -h` to see the list of supported commands and flags, such as `dbt sqlfluff lint` to lint SQL files.
From the dbt Cloud CLI, you can invoke [SQLFluff](https://sqlfluff.com/) which is a modular and configurable SQL linter that warns you of complex functions, syntax, formatting, and compilation errors. Many of the same flags that you can pass to SQLFluff are available from the dbt Cloud CLI, except those that might pose a security risk.
nghi-ly marked this conversation as resolved.
Show resolved Hide resolved

The available SQLFluff commands are:

- `lint` — Lint SQL files by passing a list of files or from standard input (stdin).
- `fix` — Fix SQL files.
- `format` — Autoformat SQL files.


To lint SQL files, run the command as follows:
nghi-ly marked this conversation as resolved.
Show resolved Hide resolved

```shell
dbt sqlfluff lint [PATHS]... [flags]
```

When no path is set, dbt lints all SQL files in the current project. To lint a specific SQL file or a directory, set `PATHS` to the path of the SQL file(s) or directory of files. To lint multiple files or directories, pass multiple `PATHS` flags.

To show detailed information on all the dbt supported commands and flags, run the `dbt sqlfluff -h` command.
nghi-ly marked this conversation as resolved.
Show resolved Hide resolved

#### Considerations
Keep the following points in mind when using SQLFluff with the dbt Cloud:

- When you run `dbt sqlfluff`, it picks up changes to your local .sqlfluff config.
- To use SQLFluff in continuous integration/continuous development, you need to have a `dbt_cloud.yml` file in your project and run commands from a valid dbt project.
- SQLFluff commands in the dbt Cloud CLI do not return exit codes yet.
When running `dbt sqlfluff` from the dbt Cloud CLI, the following are important behaviors to consider:

- dbt will read the `.sqlfluff` file if it exists for any custom configurations you might have.
nghi-ly marked this conversation as resolved.
Show resolved Hide resolved
- For continuous integration/continuous development (CI/CD) workflows, your project must have a `dbt_cloud.yml` file and you have successfully run commands from within this dbt project.
- An SQLFluff command will return an exit code of 0 if it ran without any file violations. This dbt behavior differs from SQLFluff behavior, where a linting violation returns a non-zero exit code. dbt Labs plans on addressing this in a later release.
nghi-ly marked this conversation as resolved.
Show resolved Hide resolved

## FAQs
<Expandable alt_header="How to create a .dbt directory and move your file">
Expand Down
Loading