vscode-dbt-power-user icon indicating copy to clipboard operation
vscode-dbt-power-user copied to clipboard

Execute dbt SQL fails if the query starts with a Jinga comment

Open M4Al opened this issue 1 year ago • 1 comments

Expected behavior

The query runner should ignore the Jinga comment and generate a valid SQL in the backend.

Actual behavior

Correct SQL generated

Steps To Reproduce

Take any dbt model and add a comment line as the first line

{# this is a base dimension, used to generate role playing ones#}
with final as (

    SELECT 
....

When using the Execute dbt SQL feature this query is generated:

    select *
        from (
            
with final as (

    SELECT 
...

when I remove the comment, the correct SQL is generated.

with final as (

    SELECT 
...

Log output/Screenshots

I presume the query execute feature checks if the query needs to be encapsukatedby checking if the first line/word is 'with' to detect a CTE.

This check either needs to be done after the Jinga template resolution or be more robust.

Operating System

Windows 11

dbt version

1.8.0

dbt Adapter

dbt-fabric-1.8.3

dbt Power User version

0.39.12

Are you willing to submit PR?

  • [ ] Yes I am willing to submit a PR!

M4Al avatar May 23 '24 10:05 M4Al

Sweeping

0%

💎 Sweep Pro: You have unlimited Sweep issues

Actions

  • [ ] ↻ Restart Sweep

Step 1: 🔎 Searching

I'm searching for relevant snippets in your repository. If this is your first time using Sweep, I'm indexing your repository, which will take a few minutes.


[!TIP] To recreate the pull request, edit the issue title or description.

This is probably a bug in dbt-fabric. Please raise it there. We reuse the dbt show feature for query execution.

mdesmet avatar Sep 17 '24 21:09 mdesmet