AltimateAI / vscode-dbt-power-user

This extension makes vscode seamlessly work with dbt™: Auto-complete, preview, column lineage, AI docs generation, health checks, cost estimation etc
https://www.altimate.ai
MIT License
453 stars 86 forks source link

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

Closed M4Al closed 2 weeks ago

M4Al commented 4 months ago

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?

sweep-ai[bot] commented 4 months ago
Sweeping

0%
💎 Sweep Pro: You have unlimited Sweep issues

Actions


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

mdesmet commented 2 weeks ago

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