# Run selected code only in dbt Cloud IDE

**URL:** <https://discourse.getdbt.com/t/run-selected-code-only-in-dbt-cloud-ide/5009>\
**Category:** Help\
**Tags:** dbt-cloud\
**Created:** [October 5, 2022, 7:21pm UTC](https://discourse.getdbt.com/t/run-selected-code-only-in-dbt-cloud-ide/5009 "2022-10-05T19:21:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![obar1](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/obar1/32/1221_2.png) [@obar1](https://discourse.getdbt.com/u/obar1)\
**Post date:** [October 5, 2022, 7:21pm UTC](https://discourse.getdbt.com/t/run-selected-code-only-in-dbt-cloud-ide/5009/1 "2022-10-05T19:21:49Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/2X/c/c5e02abbd3f352333a86e8b172f66e2752b787f4.png)

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

---

<div class="post-metadata">

**Author:** ![joellabes](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/joellabes/32/3980_2.png) [@joellabes](https://discourse.getdbt.com/u/joellabes)\
**Post date:** [October 5, 2022, 10:26pm UTC](https://discourse.getdbt.com/t/run-selected-code-only-in-dbt-cloud-ide/5009/2 "2022-10-05T22:26:34Z")

</div>

Hey @obar1! Thanks for the feedback.

> [@obar1](#):
>
> 1. selecting a portion of a query it just runs whathever is on the pad not only the selected one

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](https://docs.getdbt.com/docs/dbt-cloud/cloud-ide/ide-beta)

> [@obar1](#):
>
> 1. if you use a jinja macro and use – to comment it out still it’s parsed in compile and it screw the query

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

> [@Why does Jinja parse the commented-out macros in SQL queries?](https://discourse.getdbt.com/t/why-does-jinja-parse-the-commented-out-macros-in-sql-queries/4708/2):
>
> Jinja context should be commented out with {# … #}

---

<div class="post-metadata">

**Author:** ![obar1](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/obar1/32/1221_2.png) [@obar1](https://discourse.getdbt.com/u/obar1)\
**Post date:** [October 6, 2022, 9:22am UTC](https://discourse.getdbt.com/t/run-selected-code-only-in-dbt-cloud-ide/5009/3 "2022-10-06T09:22:10Z")

</div>

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’)}}  
#}

---

<div class="post-metadata">

**Author:** ![joellabes](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/joellabes/32/3980_2.png) [@joellabes](https://discourse.getdbt.com/u/joellabes)\
**Post date:** [October 6, 2022, 10:48pm UTC](https://discourse.getdbt.com/t/run-selected-code-only-in-dbt-cloud-ide/5009/4 "2022-10-06T22:48:16Z")

</div>

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`](https://docs.getdbt.com/reference/dbt-jinja-functions/ref#forcing-dependencies) or something like this:

```sql
--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

```sql
/*
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:

```sql
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.

---

<div class="post-metadata">

**Author:** ![obar1](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/obar1/32/1221_2.png) [@obar1](https://discourse.getdbt.com/u/obar1)\
**Post date:** [October 7, 2022, 11:41am UTC](https://discourse.getdbt.com/t/run-selected-code-only-in-dbt-cloud-ide/5009/5 "2022-10-07T11:41:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/a7a7ca1fe379aaf90952b0e13118a817babcd14f.png) [@system](https://discourse.getdbt.com/u/system)\
**Post date:** [October 14, 2022, 11:41am UTC](https://discourse.getdbt.com/t/run-selected-code-only-in-dbt-cloud-ide/5009/6 "2022-10-14T11:41:21Z")

</div>

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