Run selected code only in dbt Cloud IDE

It appears in dbt cloud using scratchpad
there are some issues

  1. selecting a portion of a query it just runs whathever is on the pad not only the selected one

  1. if you use a jinja macro and use – to comment it out still it’s parsed in compile and it screw the query

Hey @obar1! Thanks for the feedback.

Our rebuilt IDE, currently in beta, resolves this! You can sign up to join the beta here About the dbt Cloud IDE | dbt Developer Hub

You can’t comment out a Jinja command with a SQL -- comment. See this:

1 Like

I was aware about the jinja comment syntax
hope the nex ide will be smart to handle automatically that

ex
select col1
from {{ref(‘table_a’)}}

/*
select col1
from {{ref(‘table_a’)}}
*/

your workaround would be

{#
select col1
from {{ref(‘table_a’)}}
#}

It’s not really a “smartness” thing - Jinja comments and SQL comments are useful in different contexts. Sometimes you want to include the result of a commented out jinja statement in your sql, e.g. forcing a dependency in ref or something like this:

--table created at {{ modules.datetime.datetime.now() }}

select * 
from {{ ref('my_model') }}

It is a bit confusing that there’s two comment styles, but it’s because there’s actually two languages in use.

FWIW, if you did

/*
select col1
from {{ref(‘table_a’)}}
*/

then you’d be OK as long as the ref resolved. If the model doesn’t exist then you will get an error.

Compare these two:

select id,
--{{ dbt_utils.pivot() }}   --this won't work
/*{{ dbt_utils.pivot() }}*/ --this will
from {{ ref('my_model') }}

The former won’t work because only the first line of compiled SQL will be commented out, which is multiple lines. Whereas the block comment will comment out the multiple lines of generated SQL.

1 Like

I think /* will be my std */
it helps with ctes in cascade to break down and rerun things by piece …

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.