maddyblue / sqlfmt

SQL formatter with width-aware output
https://sqlfum.pt
Apache License 2.0
417 stars 22 forks source link

WITH RECURSIVE not implemented #42

Closed patrickgaskill closed 4 years ago

patrickgaskill commented 5 years ago

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.

maddyblue commented 5 years ago

This is because cockroach doesn't support RECURSIVE. See https://github.com/cockroachdb/cockroach/issues/21085.

tilinna commented 5 years ago

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! :)

maddyblue commented 5 years ago

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.

tilinna commented 4 years ago

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

maddyblue commented 4 years ago

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