Skip to content

Commit

Permalink
Update linter docs for dbt Cloud CLI (#5753)
Browse files Browse the repository at this point in the history
## What are you changing in this pull request and why?

Provide more docs details for the linter that's available from the dbt
Cloud CLI

closes #5715 

## Checklist
- [x] Review the [Content style
guide](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/content-style-guide.md)
so my content adheres to these guidelines.
- [x] For [docs
versioning](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#about-versioning),
review how to [version a whole
page](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#adding-a-new-version)
and [version a block of
content](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#versioning-blocks-of-content).
- [x] Needs review from product eng

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matt Shaver <[email protected]>
  • Loading branch information
3 people authored Jul 16, 2024
1 parent d1cf3e3 commit a9b12dd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
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.

The available SQLFluff commands are:

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


To lint SQL files, run the command as follows:

```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.

#### 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 reads the `.sqlfluff` file, if it exists, for any custom configurations you might have.
- 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.

## FAQs
<Expandable alt_header="How to create a .dbt directory and move your file">
Expand Down
1 change: 1 addition & 0 deletions website/docs/docs/dbt-versions/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Release notes are grouped by month for both multi-tenant and virtual private clo
[^*] The official release date for this new format of release notes is May 15th, 2024. Historical release notes for prior dates may not reflect all available features released earlier this year or their tenancy availability.

## July 2024
- **New**: The ability to lint your SQL files from the dbt Cloud CLI is now available. To learn more, refer to [Lint SQL files](/docs/cloud/configure-cloud-cli#lint-sql-files).
- **New**: Introduced Semantic validations in CI pipelines. Automatically test your semantic nodes (metrics, semantic models, and saved queries) during code reviews by adding warehouse validation checks in your CI job using the `dbt sl validate` command. You can also validate modified semantic nodes to guarantee code changes made to dbt models don't break these metrics. Refer to [Semantic validations in CI](/docs/deploy/ci-jobs#semantic-validations-in-ci) to learn about the additional commands and use cases.

## June 2024
Expand Down

0 comments on commit a9b12dd

Please sign in to comment.