dbtsqlfluff

Undefined jinja template variable: 'dbt_utils'


How to fix the below issue in sqlfluff linting:

Undefined jinja template variable: 'dbt_utils'. I have included templater = dbt in the .sqlfluff file.

Code being parsed:

config(
schema='business',
unique_key = 'calendar_id'
)
}}
WITH rpt_fact_calendar AS (
     SELECT * FROM {{ ref('stg_calendar') }}
)
SELECT
    {{ dbt_utils.generate_surrogate_key(['listing_id', 'till_date']) }}
AS calendar_id, rpt_fact_calendar.*
FROM 
    rpt_fact_calendar



Solution

  • In my case, I was running sqlfluff command from not the same directory as the .sqlfluff config file. The .sqlfluff config file was outside my dbt project directory. I am closing the question.