Demonstration of sqlfluff plugin ignoring dialect specified in a configuration file #2571
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

The sqlfluff plugin script is defined as follows:
When a dialect is specified as a command line option it takes precedence over the option in a configuration file. So if a repository has a configuration file defined as:
The dialect will be
ansi, ignoring the value in the configuration file. This PR intentionally introduces a failing test to demonstrate the behavior. The SQL in the PR is supposed to produce a lint issue (in postgres), but doesn't because the dialect is set to ansi.The sqlfluff plugin's use of a
--dialect ansieffectively creates a smart default; the sqlfluff linter itself does not have one. If you run sqlfluff (not the plugin), without a dialect (it can be passed as a command line argument or placed in a configuration file), sqlfluff raises an error.A fix for this plugin issue should retain the smart default for backwards compatibility. While removing the
--dialect ansifrom the script directive will cause the linter to successfully honor the dialect in configuration files, it will raise an error for any users of the plugin who haven't specified a dialect.One possible solution to maintain backwards compatibility would be initialize the plugin with a configuration file with a default dialect. This has its own issues -- e.g. if the customer has defined a dialect already, it should be honored. sqlfluff supports 5 different kinds of configuration files -- we could conditionally add the lowest precedent configuration file if it doesn't exist. In those cases it would be overridden by higher precedent configuration files, or not set if it already exists. This is pretty complex though.