sqlfluff fix LT02 is not consistent for jinja statements
Search before asking
- [X] I searched the issues and found no similar issues.
What Happened
Hello, I have an issue with LT02 rule, sqlfluff reports that indentation is wrong but the sqlfluff's fix command can't fix it - it switches between two states ( Expected indent of 8 spaces and Expected indent of 12 spaces )
Expected Behaviour
sqlfluff's fix changes should be consistent
Observed Behaviour
sqlfluff's fix changes are not consistent, it switches between "Expected indent of 8/12 spaces"
How to reproduce
sqlfluff lint models/file.sql L: 19 | P: 1 | LT02 | Expected indent of 8 spaces. [layout.indent]
sqlfluff fix models/file.sql == [models/file.sql] FIXED
sqlfluff lint models/file.sql L: 19 | P: 1 | LT02 | Expected indent of 12 spaces. [layout.indent]
models/file.sql content:
with raw as (
select * from {{ ref('stg_test_test') }}
),
{% set group_titles = [
("name1", "name5"),
("name2", "name6")
] %}
final as (
select
product_id,
{% for title, alias in group_titles %}
MAX(IFF(group_title = '{{ title }}', group_flag, null))::varchar(1) as {{ alias }}
{% if not loop.last %},{% endif %}
{% endfor %}
from raw
group by product_id
)
select * from final
Dialect
dialect: snowflake templater: jinja
Version
3.0.5
Configuration
main .sqlfluff config:
dialect = snowflake
templater = jinja
runaway_limit = 10
max_line_length = 119
indent_unit = space
tab_space_size = 4
rules = layout.start_of_file, layout.cte_bracket, ST01, ST02, ST03, ST04, ST05, ST07, ST08
models/.sqlfluff config:
[sqlfluff]
rules =
exclude_rules = RF04,ST06,AM04
[sqlfluff:rules:jinja.padding]
single_space = true
[sqlfluff:rules:ambiguous.column_references]
group_by_and_order_by_style = consistent
[sqlfluff:rules:references.consistent]
single_table_references = consistent
[sqlfluff:rules:aliasing.expression]
allow_scalar = True
Are you willing to work on and submit a PR to address the issue?
- [ ] Yes I am willing to submit a PR!
Code of Conduct
- [X] I agree to follow this project's Code of Conduct