-
-
Notifications
You must be signed in to change notification settings - Fork 894
Closed
DripEmail/sqlfluff
#1Labels
bugSomething isn't workingSomething isn't working
Description
Search before asking
- I searched the issues and found no similar issues.
What Happened
When I have a simple query containing jinja, i get the fault that LT01 is voilated, alias_expressions are expected to be aligned.
select
{{ generate_surrogate_key('test', ['a', 'b', 'c']) }} as test_key,
b as b_col
from {{ ref("test") }}When I align the aliasses like below, I still get the same error
select
{{ generate_surrogate_key('test', ['a', 'b', 'c']) }} as test_key,
b as b_col
from {{ ref("test") }}When I use sqlfluff to 'fix' this issue, I get the following result, but this looks like its aligning on the macro's result (or something else). The following violation is LT05, line too long.
select
{{ generate_surrogate_key('test', ['a', 'b', 'c']) }} as test_key,
b as b_col
from {{ ref("test") }}Expected Behaviour
SQLFluff to accept alignment on the actual jinja, not on any parsed result.
Observed Behaviour
SQLFluff seems to align on a generated macro, at least not whats visible in the editor
How to reproduce
Use the supplied queries
Dialect
databricks
Version
2.3.4
Configuration
[sqlfluff]
templater = jinja
dialect = databricks
sql_file_exts = .sql
max_line_length = 125
exclude_rules = ST06, AM05, L014, L029
[sqlfluff:templater:jinja]
apply_dbt_builtins = True
load_macros_from_path=macros
[sqlfluff:indentation]
tab_space_size = 4
indent_unit = space
[sqlfluff:rules:capitalisation.keywords]
capitalisation_policy = lower
[sqlfluff:layout:type:alias_expression]
# We want non-default spacing _before_ the alias expressions.
spacing_before = align
# We want to align them within the next outer select clause.
# This means for example that alias expressions within the FROM
# or JOIN clause would _not_ be aligned with them.
align_within = select_clause
# The point at which to stop searching outward for siblings, which
# in this example would likely be the boundary of a CTE. Stopping
# when we hit brackets is usually a good rule of thumb for this
# configuration.
align_scope = bracketed
[sqlfluff:rules:references.keywords]
# Comma separated list of words to ignore for this rule
ignore_words = element, no, rownum, resource, date, type, month, year, day, leading
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
- I agree to follow this project's Code of Conduct
MDTGRD
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working