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

Issue with nested jinja call and endcall syntax with v0.14.1 #338

Closed
AndrewLane opened this issue Dec 6, 2022 · 3 comments · Fixed by #340
Closed

Issue with nested jinja call and endcall syntax with v0.14.1 #338

AndrewLane opened this issue Dec 6, 2022 · 3 comments · Fixed by #340
Labels
bug Something isn't working

Comments

@AndrewLane
Copy link

Describe the bug
sqlfmt error with jinja syntax for start and endcall that used to parse previously (in v0.13.0)

Similar to issue #335

To Reproduce
Run sql-fmt on the following code from https://github.com/EqualExperts/dbt-unit-testing#different-ways-to-build-mock-values:

{% call dbt_unit_testing.test('customers', 'should sum order values to calculate customer_lifetime_value') %}
  
  {% call dbt_unit_testing.mock_ref ('stg_customers', {"input_format": "csv"}) %}
    customer_id, first_name, last_name
    1,'',''
  {% endcall %}
  
  {% call dbt_unit_testing.mock_ref ('stg_orders', {"input_format": "csv"}) %}
    order_id,customer_id,order_date
    1001,1,null
    1002,1,null
  {% endcall %}
  
  {% call dbt_unit_testing.mock_ref ('stg_payments', {"input_format": "csv"}) %}
    order_id,amount
    1001,10
    1002,10
  {% endcall %}

  {% call dbt_unit_testing.expect({"input_format": "csv"}) %}
    customer_id,customer_lifetime_value
    1,20
  {% endcall %}
{% endcall %}

Expected behavior
Should not fail to parse

Actual behavior

sqlfmt encountered an error: Encountered closing bracket '{% endcall %}' at position xxx, before matching opening bracket. Context: {% endcall %}

Additional context
Version v0.14.0 appears to break this and the fix in v0.14.1 did not resolve it

@tconbeer
Copy link
Owner

tconbeer commented Dec 6, 2022

Yeah, this makes sense. I didn't know call blocks could be nested. Fix for this will be a little more involved but I'll prioritize it

@tconbeer tconbeer added the bug Something isn't working label Dec 6, 2022
@tconbeer
Copy link
Owner

@AndrewLane this is fixed in the most recent commit. I'll release this as 0.14.2 later today

@AndrewLane
Copy link
Author

@AndrewLane this is fixed in the most recent commit. I'll release this as 0.14.2 later today

I tried it out and it works great. Thanks!

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

Successfully merging a pull request may close this issue.

2 participants