Question

How to comment out a block of code

  • 20 May 2015
  • 0 replies
  • 10283 views

Userlevel 5
Badge

In order to comment out an entire block of code in the LookML editor, following these steps:



  1. Select the lines you want to comment out

  2. Press ⌘+/ on a Mac, or ctrl+/ on a Windows computer


Your code should now be commented out with a # symbol, like this:


#  - dimension: id                         
# type: int
# primary_key: true
# sql: ${TABLE}.id

Read about all the keyboard shortcuts available in Looker here.


Commenting out SQL blocks


If you are commenting out lines that are entirely within a SQL code block, you will want to manually add SQL comment notation. Note that SQL comments must appear only in SQL blocks that are indented beyond the LookML parameter above it. This looks like:


Multi-line comments:


- view: user_order_facts
derived_table:
sql: |
/*
SELECT
users.id as user_id
, COUNT(*) as lifetime_orders
, MAX(orders.date) as most_recent_purchase_date
FROM orders
GROUP BY user.id
/*

Single line comments:


- view: user_order_facts
derived_table:
sql: |
SELECT
users.id as user_id
, COUNT(*) as lifetime_orders
-- , MAX(orders.date) as most_recent_purchase_date
FROM orders
GROUP BY user.id

0 replies

Be the first to reply!

Reply