sqlfluff "Parse error" / unparsable SQL in CI
sqlfluff could not build a parse tree for the SQL, so it reports a parse error or unparsable section. This is almost always the wrong dialect or templating that was not rendered before linting.
What this error means
A sqlfluff lint step reports "Parse error" or "Found unparsable section" pointing at valid-looking SQL, and fails before any lint rule is evaluated.
sqlfluff
== [models/orders.sql] FAIL
L: 7 | P: 1 | PRS | Line 7, Position 1: Found unparsable section:
'QUALIFY row_number() over (...'Common causes
The dialect does not support the syntax
Linting with the wrong dialect (for example ansi on Snowflake QUALIFY) makes valid SQL unparsable.
Jinja templating was not rendered
Raw {{ ref(...) }} or {% ... %} left in the SQL cannot be parsed unless the correct templater renders it first.
How to fix it
Set the correct dialect
- Identify the warehouse dialect the SQL targets.
- Set it in
.sqlfluffor pass--dialect. - Re-run lint so the parser understands the syntax.
Terminal
sqlfluff lint models/orders.sql --dialect snowflakeUse the right templater for Jinja SQL
For dbt models, use the dbt templater so ref and macros render before parsing.
.sqlfluff
[sqlfluff]
templater = dbt
dialect = snowflakeHow to prevent it
- Set the dialect explicitly for every project.
- Choose a templater that matches your SQL (jinja or dbt).
- Lint rendered SQL, not raw templates.
Related guides
sqlfluff "no dialect was specified" in CIFix sqlfluff "No dialect was specified" in CI. sqlfluff refuses to lint without a dialect; set it in .sqlfluf…
sqlfluff dbt templater error in CIFix sqlfluff dbt templater failures in CI. The dbt templater needs sqlfluff-templater-dbt, a valid profile, a…
sqlfluff lint rule failures (L010 and friends) in CIFix sqlfluff lint failures in CI. Rule violations like L010 (keyword capitalization) return a non-zero exit t…