format
Autoformat SQL files.
This effectively force applies sqlfluff fix with a known subset of fairly stable rules. Enabled rules are ignored, but rule exclusions (via CLI) or config are still respected.
PATH is the path to a sql file or directory to lint. This can be either a file (path/to/file.sql), a path (directory/of/sql/files), a single (-) character to indicate reading from stdin or a dot/blank (./) which will be interpreted like passing the current working directory as a path argument.
Usage
bash
sqlfluff format [OPTIONS] [paths]Arguments
| Argument | Description |
|---|---|
paths |
Options
| Option | Type | Default | Description |
|---|---|---|---|
-n, --nocolor | Boolean | — | No color - output will be without ANSI color codes. |
-v, --verbose | Integer | — | Verbosity, how detailed should the output be. This is stackable, so -vv is more verbose than -v. For the most verbose option try -vvvv or -vvvvv. |
--version | Boolean | false | Show the version and exit. |
--stdin-filename | Path | — | When using stdin as an input, load the configuration as if the contents of stdin was in a file in the listed location. This is useful for some editors that pass file contents from the editor that might not match the content on disk. |
--library-path | String | — | Override the library_path value from the [sqlfluff:templater:jinja] configuration value. Set this to none to disable entirely. This overrides any values set by users in configuration files or inline directives. |
--disable-noqa-except | String | — | Ignore all but the listed rules inline noqa comments. |
--disable-noqa | Boolean | — | Set this flag to ignore inline noqa comments. |
--logger | Choice (6 options) | Sentinel.UNSET | Choose to limit the logging to one of the loggers. |
--bench | Boolean | false | Set this flag to engage the benchmarking tool output. |
-i, --ignore | String | — | Ignore particular families of errors so that they dont cause a failed run. For example --ignore parsing would mean that any parsing errors are ignored and dont influence the success or fail of a run. --ignore behaves somewhat like noqa comments, except it applies globally. Multiple options are possible if comma separated: e.g. --ignore parsing,templating. |
--encoding | String | — | Specify encoding to use when reading and writing files. Defaults to autodetect. |
--ignore-local-config | Boolean | false | Ignore config files in default search path locations. This option allows the user to lint with the default config or can be used in conjunction with --config to only reference the custom config file. |
--config | Path | — | Include additional config file. By default the config is generated from the standard configuration files described in the documentation. This argument allows you to specify an additional configuration file that overrides the standard configuration files. N.B. cfg format is required. |
-e, --exclude-rules | String | — | Exclude specific rules. For example specifying --exclude-rules LT01 will remove rule LT01 (Unnecessary trailing whitespace) from the set of considered rules. This could either be the allowlist, or the general set if there is no specific allowlist. Multiple rules can be specified with commas e.g. --exclude-rules LT01,LT02 will exclude violations of rule LT01 and rule LT02. |
-r, --rules | String | — | Narrow the search to only specific rules. For example specifying --rules LT01 will only search for rule LT01 (Unnecessary trailing whitespace). Multiple rules can be specified with commas e.g. --rules LT01,LT02 will specify only looking for violations of rule LT01 and rule LT02. |
-t, --templater | Choice: raw, jinja, python, placeholder | — | The templater to use (default=jinja) |
-d, --dialect | String | — | The dialect of SQL to lint |
--disregard-sqlfluffignores | Boolean | false | Perform the operation regardless of .sqlfluffignore configurations |
--warn-unused-ignores | Boolean | false | Warn about unneeded -- noqa: comments. |
--persist-timing | String | — | A filename to persist the timing information for a linting run to in csv format for external analysis. NOTE: This feature should be treated as beta, and the format of the csv file may change in future releases without warning. |
--disable-progress-bar | Boolean | false | Disables progress bars. |
-p, --processes | Integer | — | The number of parallel processes to run. Positive numbers work as expected. Zero and negative numbers will work as number_of_cpus - number. e.g -1 means all cpus except one. 0 means all cpus. |
-x, --fixed-suffix | String | — | An optional suffix to add to fixed files. |
--recursion-limit | Integer | — | Set the Python recursion limit before formatting. |