quarylabs / sqruff

Fast SQL formatter/linter
https://playground.quary.dev/?secondary=Format
Apache License 2.0
328 stars 14 forks source link

Dialect: DuckDB "LOAD spatial;" causes indentation rules to not be enforced #882

Open gregorywaynepower opened 2 days ago

gregorywaynepower commented 2 days ago

Hey folks! I'm currently using sqruff 0.19.1 installed via cargo on Windows 10 working with the DuckDB dialect. For some reason a LOAD spatial; is throwing off the rest of my linting rules.

LOAD spatial;

-- SUMMARIZE cpd_incidents;
-- DESCRIBE cpd_incidents;

SELECT location FROM cpd_incidents LIMIT 1;

SELECT
    crimeday AS "Crime Day",
    count(crimeday) AS "Crime Count"
FROM
    cpd_incidents
WHERE
    crimeday IS NOT NULL
GROUP BY
    crimeday
ORDER BY
    "Crime Count" DESC;

Becomes

LOAD spatial ;

-- SUMMARIZE cpd_incidents;
-- DESCRIBE cpd_incidents;

SELECT location FROM cpd_incidents LIMIT 1 ;

SELECT
crimeday AS "Crime Day",
count (crimeday) AS "Crime Count"
FROM
cpd_incidents
WHERE
crimeday IS NOT NULL
GROUP BY
crimeday
ORDER BY
"Crime Count" DESC ;

When I remove the LOAD spatial; my linting rules are parsed properly.

-- LOAD spatial;

-- SUMMARIZE cpd_incidents;
-- DESCRIBE cpd_incidents;

SELECT location FROM cpd_incidents LIMIT 1;

SELECT
    crimeday AS "Crime Day",
    count(crimeday) AS "Crime Count"
FROM
    cpd_incidents
WHERE
    crimeday IS NOT NULL
GROUP BY
    crimeday
ORDER BY
    "Crime Count" DESC;
benfdking commented 1 day ago

This is probably because at the moment we don't support the load syntax.

gregorywaynepower commented 22 hours ago

That's valid--it's very much a feature that has seen its fare share of changes in DuckDB.