Skip to content
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

[Rule] LT01 - spacing #830

Open
jordandakota opened this issue Oct 2, 2024 · 6 comments
Open

[Rule] LT01 - spacing #830

jordandakota opened this issue Oct 2, 2024 · 6 comments

Comments

@jordandakota
Copy link

L: 4 | P: 20 | LT01 | Expected single whitespace between "{" and "{".
| [layout.spacing]

In sqlfluff, this works:

[sqruff:layout:type:placeholder]
spacing_within = any
spacing_before = any
spacing_after = any

and adding -- noqa: LT01 to a line allows inline ignoring, but neither approaches work with current version of sqruff.

@benfdking
Copy link
Collaborator

Thanks for the feedback, will look into it.

@benfdking
Copy link
Collaborator

Related to #855, this should add the noqa functionality

SELECT   1; --noqa: disable=LT01

@jordandakota
Copy link
Author

jordandakota commented Oct 8, 2024

Will the added noqa allow me to do something like:

with

generaljournal as (
select * from {{ source ("schema", "table") }}
-- noqa: disable=all
{% if is_incremental() %}
    {% call statement ('max_id', fetch_result = True) %}
    SELECT max(ID) as max_id FROM {{ this }}
    {% endcall %}
    {% set max_id = load_result('max_id')['data'][0][0] %}
    where ID > {{ max_id }}
{% endif %}
-- noqa: enable=all
)

We're getting an issue where having any of the {% jinja style operators in the beginning of the file causes downstream lints to end up looking like:

FROM GENERALJOURNAL GJ
JOIN businessentity BE
ON GJ.IDBEOWNER = BE.ID
JOIN GENERALJOURNALLINE GJL
ON GJ.ID = GJL.IDGENERALJOURNAL
JOIN GENERALLEDGERTRANSACTION GLT
ON GLT.IDGENERALJOURNALLINE = GJL.ID

@benfdking
Copy link
Collaborator

benfdking commented Oct 8, 2024

This won't be able to do a range just yet, but let me look into it. Now that we have the infrastructure, it should be much easier.

Really, what this needs is a DBT templater... and I am at Coalesce, so I might feel inspired.

@jordandakota
Copy link
Author

jordandakota commented Oct 8, 2024

This won't be able to do a range just yet, but let me look into it. Now that we have the infrastructure, it should be much easier.

Really, what this needs is a DBT templater... and I am at Coalesce, so I might feel inspired.

Sounds good Ben. I agree, a templater would work, but I can say that with this fix here it already has about 95% coverage on my project that uses dbt. It's just the incremental models that always have the jinja at the start where it fuzzes up and left align/capitalizes everything regardless of my settings. Will get a blog post out when we're working well, amazing tool.

@benfdking
Copy link
Collaborator

benfdking commented Oct 9, 2024

Latest version should have this in it. Just pushing to our brew.

For the docs on it: https://github.com/quarylabs/sqruff?tab=readme-ov-file#ignoring-errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants