cockroachdb / cockroachdb/cockroach

select `window function` and a subquery with `ON` condition is not allowed

Open
#132,818 3 comments 0 reactions 0 assignees View on GitHub
branch-release-24.1 branch-release-24.2 C-bug O-community T-sql-queries X-blathers-triaged
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Describe the problem**

Select `window function` and a subquery with `ON` condition is not allowed: `ERROR: window functions are not allowed in ON`. Is this expected behaviour?

**To Reproduce**
```sql
create table t1 (c1 int);

select
(
select 1
from (t1 as ref_3
full outer join
t1 as ref_4 on (1=1))
limit 1
) as c,

pg_catalog.count(1) over (partition by ref_0.c1)

from
t1 as ref_0
;
```

```
ERROR: count(): window functions are not allowed in ON
```

**Expected behavior**
in postgres:
```
c | count
---+-------
(0 rows)
```

**Environment:**
- CockroachDB CCL v24.1.4 (x86_64-pc-linux-gnu, built 2024/08/26 19:15:49, go1.22.5 X:nocoverageredesign)
- Server OS: Ubuntu 22.04
- Client app: psql

Jira issue: CRDB-43287

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.