I have a dbt project which I wanna lint with SQLFLUFF and it consists of models
and macros
in which model calls macros as normal. Most of SQL codes are in macro files and models just simply call the relative macro.
The problem here is that SQLFLUFF lints only model files and skips macro files which actually contain the SQL lines of codes to be fix.
The result of running pre-commit run --files models/market/*
is like this:
sqlfluff-lint............................................................Passed
sqlfluff-fix.............................................................Passed
But in practice, macro files are never fixed.
here is the project structure:
project
|
|- models
|- macros
|-acm
|- .sqlfluffignore
|- setup.cfg
|- dbt_project.yml
|- .pre-commit-config.yaml
|- profiles.yml
Here is the setup.cfg
# SQLFLUFF linter configuration file
# Main body
[sqlfluff]
verbose = 1
templater = dbt
dialect = bigquery
sql_file_exts = .sql
max_line_length = 120
[sqlfluff:rules:capitalisation.keywords]
capitalisation_policy = upper
[sqlfluff.templater.dbt]
project_dir = "./"
profiles_dir = "./"
target = "target"
[sqlfluff:templater:jinja]
apply_dbt_builtins = True
[sqlfluff:templater:jinja:macros]
load_macros_from_path = macros/acm
and .sqlfluffignore
is like this:
target/
# dbt <1.0.0
dbt_modules/
# dbt >=1.0.0
dbt_packages/
and the .pre-commit-config.yaml
file is as below:
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/sqlfluff/sqlfluff
rev: 2.2.0
hooks:
- id: sqlfluff-lint
name: sqlfluff-lint
verbose: true
additional_dependencies: [
'dbt-bigquery==1.5.1',
'sqlfluff-templater-dbt==2.2.0'
]
- id: sqlfluff-fix
additional_dependencies: [
'dbt-bigquery==1.5.1',
'sqlfluff-templater-dbt==2.2.0'
]
description: "Lints sql files with `SQLFluff`"
I checked the SQLFLUFF issues on the github and couldn't find any similar issue.