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

Unrecoverable failure in Jinja templating: cannot unpack non-iterable UndefinedRecorder object #5887

Open
2 of 3 tasks
sukalpv opened this issue May 17, 2024 · 0 comments
Open
2 of 3 tasks
Labels
bug Something isn't working

Comments

@sukalpv
Copy link

sukalpv commented May 17, 2024

Search before asking

  • I searched the issues and found no similar issues.

What Happened

When formatting a sql file with jinja set var {% set a = ``}, the formatting doesn't work and lint command fails with error.

L:   1 | P:   1 |  TMP | Unrecoverable failure in Jinja templating: cannot unpack
                       | non-iterable UndefinedRecorder object. Have you
                       | correctly configured your variables?
                       | https://docs.sqlfluff.com/en/latest/configuration.html

Expected Behaviour

lint command should not fail and file should be formatted with sqlfluff fix

Observed Behaviour

lint command fails and runnig sqlfluff fix has no effect on sql

How to reproduce

Here is SQL to reproduce:

{{ config(
    schema='etl',
    materialized='table')
}}

{% set sessions_this_run = ref('snowplow_unified_base_sessions_this_run') %}
{% set lower_limit, upper_limit = snowplow_utils.return_limits_from_model(sessions_this_run, 'start_tstamp', 'end_tstamp') %}

SELECT DISTINCT event_id, derived_tstamp, agent_class, device_class
FROM  {{ ref('events_yauaa_context_tracker') }}
WHERE DATE(derived_tstamp) >= DATE({{ lower_limit }}) AND DATE(derived_tstamp) <= DATE({{ upper_limit }})

sqlfluff lint
sqlfluff fix

Dialect

dialect: bigquery
templating: jinja

Version

3.0.6

Configuration

[sqlfluff]
dialect = bigquery
templater = jinja
exclude_rules = ambiguous.column_count, structure.column_order, ambiguous.column_references, structure.unused_cte, references.qualification, ambiguous.join, structure.subquery, aliasing.unused, convention.left_join, structure.simple_case, convention.coalesce, structure.using, capitalisation.identifiers
max_line_length = 200
large_file_skip_byte_limit = 0
fix_even_unparsable = True

[sqlfluff:templater:jinja]
apply_dbt_builtins = true
load_macros_from_path = dags/dbt/models



[sqlfluff:indentation]
allow_implicit_indents = True
tab_space_size = 4

[sqlfluff:rules:aliasing.table]
aliasing = explicit
[sqlfluff:rules:aliasing.column]
aliasing = explicit
[sqlfluff:rules:aliasing.length]
min_alias_length = 1

[sqlfluff:rules:capitalisation.keywords]
capitalisation_policy = upper

[sqlfluff:rules:capitalisation.identifiers]
extended_capitalisation_policy = lower

[sqlfluff:rules:capitalisation.functions]
extended_capitalisation_policy = upper

[sqlfluff:rules:capitalisation.literals]
capitalisation_policy = lower

[sqlfluff:rules:capitalisation.types]
extended_capitalisation_policy = lower

[sqlfluff:rules:layout.long_lines]
ignore_comment_lines = True
ignore_comment_clauses = True

[sqlfluff:rules:references.keywords]
ignore_words = user,source,target,domain,account,campaign,type,operation_id,timestamp,value,date,date_,label,language,cycle,stage,week,columns,name

Are you willing to work on and submit a PR to address the issue?

  • Yes I am willing to submit a PR!

Code of Conduct

@sukalpv sukalpv added the bug Something isn't working label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant