Skip to content

Nested CTEs identation problem #290

@GabenGar

Description

@GabenGar

The structure like this:

WITH hello_world AS (
  WITH hello_another_world AS (
    WITH hello_third_world AS (
      SELECT
      FROM
      WHERE
      ORDER BY
    ), hello_third_world_again AS (
      SELECT
      FROM
      WHERE
      ORDER BY
    )
    SELECT
    FROM
    WHERE
    ORDER BY
  ), hello_another_world_again AS (
    SELECT
    FROM
    WHERE
    ORDER BY
  )
  SELECT
  FROM
  WHERE
  ORDER BY
)
SELECT
FROM
WHERE
ORDER BY

Gets formatted as:

WITH hello_world AS (
  WITH hello_another_world AS (
    WITH hello_third_world AS (
      SELECT
      FROM
      WHERE
      ORDER BY
),
      hello_third_world_again AS (
        SELECT
        FROM
        WHERE
        ORDER BY
)
        SELECT
        FROM
        WHERE
        ORDER BY
),
        hello_another_world_again AS (
          SELECT
          FROM
          WHERE
          ORDER BY
)
          SELECT
          FROM
          WHERE
          ORDER BY
)
        SELECT
        FROM
        WHERE
        ORDER BY

It is kind of a problem since nested CTEs tend to be used in complex queries in which indentation is a hint to the CTEs scope visibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions