maddyblue / sqlfmt

SQL formatter with width-aware output

Home Page:https://sqlfum.pt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WITH RECURSIVE not implemented

patrickgaskill opened this issue · comments

From the docs: https://www.postgresql.org/docs/9.1/queries-with.html

Trying to fumpt this:

WITH RECURSIVE included_parts(sub_part, part, quantity) AS (
    SELECT sub_part, part, quantity FROM parts WHERE part = 'our_product'
  UNION ALL
    SELECT p.sub_part, p.part, p.quantity
    FROM included_parts pr, parts p
    WHERE p.part = pr.sub_part
  )
SELECT sub_part, SUM(quantity) as total_quantity
FROM included_parts
GROUP BY sub_part

results in unimplemented at or near "select"

Removing RECURSIVE will let it format successfully.

This is because cockroach doesn't support RECURSIVE. See cockroachdb/cockroach#21085.

The same happens with lateral joins.

Do you know if there are plans to extend cockroach's SQL parser ahead of the actually supported PostgreSQL features? Just enough to support the formatting part.

Anyway, thanks for the great work! :)

The current cockroach parser doesn't make that kind of support easy, and we haven't done that in the past. We would like to, though, and have a similar project in mind. We will consider this need in the future.

RECURSIVE is now supported so perhaps this issue can be closed?

Built and redeployed on master. This works now. Thanks for the prompt!