Skip to main content

Blank line between CTEs

blankLineBetweenCtes writes an empty line between the CTEs of a with clause once that clause has broken over several lines.

Default: true. A CTE is a named step of the query, and an empty line between steps does what an empty line between paragraphs does: it says where one ends. Without it the closing paren of one CTE and the name of the next sit on adjacent lines, and the eye has to find the boundary itself. A with short enough to fit on one line stays on one line; the option acts only once the clause has broken.

false stacks the CTEs with nothing between them, for a project that wants its with clause as dense as a select list, or whose CTE bodies are all one line long.

It controls only the adding. An empty line you wrote between two CTEs yourself is blankLines' business and is kept under either value, and a line this option wrote is one of yours the next time the file is read, so switching it off later does not take those lines out again. In a client script whose client reads an empty line as the end of a statement, it is forced off whatever it is set to.

Two CTEs, with and without​

with first_stage as (select id, name, created_at from raw_customers where created_at > '2024-01-01'), second_stage as (select id, name from first_stage where name is not null) select * from second_stage
with
    first_stage as (
        select id, name, created_at
        from raw_customers
        where created_at > '2024-01-01'
    ),

    second_stage as (select id, name from first_stage where name is not null)
select *
from second_stage
with first_stage as (select id, name, created_at from raw_customers where created_at > '2024-01-01'), second_stage as (select id, name from first_stage where name is not null) select * from second_stage
with
    first_stage as (
        select id, name, created_at
        from raw_customers
        where created_at > '2024-01-01'
    ),
    second_stage as (select id, name from first_stage where name is not null)
select *
from second_stage