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
add sqlfluff CLI option to pass the configuration files #1244
Comments
another use case where this feature would be helpful:
with current solution in the .sqlfluff configuration file I can set only one value for "someBooleanVariable" leaving big section of my sql without linting. if I would be able to pass list of configuration files to sqlfluff CLI, I could use it like this: where: This would allow me to run sqlfluff linting twice and cover all the sql queries I have. |
This would also be useful with the addition of SQL Fluff to the GitHub Super-Linter, as typically those linter files exist within the However, slightly different to @Arshaku 's request, I'd prefer to still be able to override at a directory level. So for example most of my queries are BigQuery dialect (so that would go in the default config file specified by command line), but one directory has MySQL code, so would prefer it's own config file. |
@tunetheweb @barrywhart I'd be interested in adding this as I also use both MySQL and Snowflake in the same project. Will add a Currently we load and overwrite the config in the following order:
Option 1:
Option 2:
i.e.
Personally I would lean towards Option 1 as it's a lot more obvious which settings will be in use, but wanted to get a second opinion in case anyone felt strongly the other way? |
If I read the original issue description correctly, aren't they asking for option 2?
|
@barrywhart actually reading that back the issue is asking for option 3:
basically there are multiple separate projects with variations on a default config that is contained in a separate project. I think it would doable but it makes sense for that to be a separate I think Options 1 and 2 are more suitable for the issue of requiring multiple configs within a single project? So propose option 3 for this issue and then one of 1 or 2. |
I'd still lean to 1 for in multiple in project configurations |
I don't understand the reason for allowing overrides. If you have the ability to place a .sqlfluff config file, then you should place one in the top level. To me the ability to provide a config file is most useful for those that want to store the config file separately for whatever reason. Therefore it should not require overrides IMHO. On the other hand, if an override file exists maybe it should be used as could be confusing if it's not used 🤔 But to be honest, while I wanted this initially (mostly cause that's how the GitHub Super Linter works for other linters), I personally have gone away from needing this and just got use to having it in the folder structure so less of a priority to me. I do think it would be useful for the simple API thought as discussed in #1274 and in more detail in #1419 (comment) |
In the case they describe, does the exact order matter? IIUC, they're saying they'd define the high-level config in I agree that 1 is good for the case you describe, so I'm in favor of 1 as well as 2 or 3. Think it's worth asking (possibly creating a poll) in the SQLFluff Slack, to get more input? More than once, I've learned the hard way that dbt users are almost a separate species of user. 🤣 |
@tunetheweb that was my thought process for 1 too 👍
@barrywhart I'll create a poll in the slack 👍 Let's keep it simple and say order doesn't matter then so between 1 or 2 |
Overrides won't be useful for most people, I think. One plausible scenario I can imagine is: you have a large (probably dbt) project written in various styles and levels of SQLFluff compliance. You're gradually cleaning it all up, but it's taking weeks or months, and you want to disable certain rules or use more relaxed settings for directories that have yet to be cleaned up. (I think @alanmcruickshank went through a process like this in the early days at Tails. (For more context, see the team rollout guide here.) NOTE: In this comment, I'm just trying to provide context, not argue for a particular decision. |
Overrides would be helpful to fix this issue I opened a while back where SQLFluff picks up the wrong dbt config: #1468. |
I guess the nice thing about overrides is that even if someone doesn't want to use them they can just not have sqlfluff config files in the current directory and keep their various sqlfluff configs in a separate folder that they reference via the CLI/API to get the same independent functionality of Option 1 |
I would like to have possibility to pass sqlfluff configuration files via CLI option (instead of current predefined list of directories to look up for config files) with similar inheritance/override logic we have now.
The use case for which I need it:
I have multiple python projects in my company, and they all use a python module I've created which contains all the common configuration and functionality used by all my projects. So now I want to put most the sqlfluff configuration (like the rule configurations, excluded rules, etc) in the shared module and inherit from there, as those configs will be the same for all my projects, but for example, jinja context variables are project-specific, so I don't want to put them in the config file in the shared python module. I want to have those jinja context variables per-project and have them within the project directory.
And when running the sqlfluff command from the project, I can for example list 2 config files - one from the project and one from the installed python module.
Does this make sense?
The text was updated successfully, but these errors were encountered: