vscode-sqlfluff icon indicating copy to clipboard operation
vscode-sqlfluff copied to clipboard

DBT project in sub-folder

Open infused-kim opened this issue 4 years ago • 2 comments

Hi,

First of all, thank you for creating this amazing extension. I have discovered a potential bug, or perhaps at least something that could be documented better.

My folder structure looks like this:

vscode_workspace_folder
├── dax_code
├── dbt_model
│   ├── analysis
│   ├── data
│   ├── dbt_modules
│   ├── logs
│   ├── macros
│   ├── models
│   ├── snapshots
│   ├── target
├── erd_diagrams
├── sql_functions
└── tmp

I am opening vscode_workspace_folder as my workspace folder in vscode, but my DBT folder is in a sub-folder. This causes sqlfluff to not work on sql files that contain custom macros.

There is no error or logging anywhere, it just doesn't work.

Through trial and error I have narrowed it down to jinja-SQL files that are using custom macros.

And when I open the DBT folder directly, then everything works. It picks up my sqlfuff file and uses the DBT templater to do the linting as expected.

Greetings, kim

infused-kim avatar Feb 19 '21 08:02 infused-kim

Hi @infused-kim 👋 , welcome to the project

Thank you for raising the issue, this is a known missing feature: https://github.com/sqlfluff/sqlfluff/issues/601

It is also mentioned in the docs here: https://docs.sqlfluff.com/en/stable/configuration.html?highlight=dbt%20templater#known-caveats

dmateusp avatar Feb 19 '21 09:02 dmateusp

Thank you for bringing up this issue. I'm having the same problem. I've exactly same dbt project structure dbt project is a subdirectory in my workspaceFolder. I've configured templater = dbt inside .sqlfluff and files to ignore inside .sqlfluffignore in the workspaceFolder. When I execute sqlfluff from the workspaceFolder directory, no lining violation are found. But, when I execute sqlfluff from my dbt project subdirectory, it works properly and fixes the file using the .sqlfluff configurations.

Same issue with sqlfluff pre-commit hooks. When I run pre-commit hook, no lingting violations are found, which is not right.

SarahAyaz avatar Aug 17 '23 12:08 SarahAyaz