cockroachdb / cockroachdb/cockroach

Support WITH clause also in subqueries like PostgreSQL

Open
#131,011 1 comment 0 reactions 0 assignees View on GitHub
C-enhancement O-community T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

PostgreSQL supports a `with` clause in subqueries, but CockroachDB doesn't. Would be nice to add support for that. Here a sample query:

```sql
select (
with recursive a as (
select 1 v
union all
select r.v + 1
from a r
where r.v < 10
)
select count(*) from a
)
```

This is just a toy example, but the nice thing about this feature, is that we can do "lateral" recursive queries i.e. a recursive query per outer row.

Jira issue: CRDB-42337

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.