Skip to content
Latchkey

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

  1. Identify the warehouse dialect the SQL targets.
  2. Set it in .sqlfluff or pass --dialect.
  3. Re-run lint so the parser understands the syntax.
Terminal
sqlfluff lint models/orders.sql --dialect snowflake

Use 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 = snowflake

How 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →