I can't test subqueries independently. Commenting the rest of the code doesn't work

Screen Link:

My Code:

-- WITH 
--     india AS
--         (
--         SELECT * FROM customer
--         WHERE country = "India"
--         ),
--     customer_total AS
--         (
--         SELECT c.first_name || " " || c.last_name customer_name,
--                SUM(i.total) total_purchases,
--                c.customer_id
--         FROM customer c
--         INNER JOIN invoice i ON c.customer_id = i.invoice_id
--         GROUP BY 1
--         )
        
-- SELECT ct.customer_name customer_name,
--        ct.total_purchases total_purchases
-- FROM customer_total ct
-- INNER JOIN india ind ON ct.customer_id = ind.customer_id
-- GROUP BY 1
-- ORDER BY 1;
          
SELECT c.first_name || " " || c.last_name customer_name,
       SUM(i.total) total_purchases,
       c.customer_id
FROM customer c
INNER JOIN invoice i ON c.customer_id = i.invoice_id
GROUP BY 1;

What I expected to happen:
My last query is run, and the terminal will ignore the lines above that are comments (prefaced by “–”)

What actually happened:
The code finished running, but there was no output

Replace this line with the output/error

Could you recommend a better way to test specific subqueries in this terminal? I think it would be useful, especially when debugging. Thanks!

1 Like

Hi @miguel.staana:

You can use multi-line SQL comments to do so for specific portions which you wish to comment out.

/*
Your multiline comment
goes here
*/
3 Likes

Hi @miguel.staana

@masterryan.prof have given you the solution.

In case you are curious why one works and the other doesn’t, you may check the link in this post.

3 Likes

Thank you! This is really helpful.

2 Likes

It’s unfortunate that the keyboard shortcut in the DQ platform (ie: ‘CTRL + /’) uses the -- style of commenting (single line) instead of /* */ (multi-line)

Do you know if there is a ‘hack’ for that? Something like: dq.display.options.comment_style = 'multi_line'? (inspired by pandas)