cockroachdb / cockroachdb/cockroach

sql: window functions next to SRFs behave differently from Postgres

Aperta
#93,386 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
C-bug O-pg-regress T-sql-queries
Lingua principale
Go
Stelle
32.5k
Fork
4.1k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Consider the following example query, minimized from a more complex one in the `tsrf.sql` pg_regress file:

```
SELECT a, lag(a) OVER(), count(*) OVER(), generate_series(1,2) FROM (select 1) as x(a);
```

CockroachDB evaluates this differently from Postgres. According to the pg_regress test case, this is because SRFs should be computed after window functions: `-- SRFs are normally computed after window functions`

CRDB
```
root@localhost:26257/defaultdb> SELECT a, lag(a) OVER(), count(*) OVER(), generate_series(1,2) FROM (select 1) as x(a);

a | lag | count | generate_series
----+------+-------+------------------
1 | NULL | 2 | 1
1 | 1 | 2 | 2
(2 rows)
```

PG
```
jordan=# SELECT a, lag(a) OVER(), count(*) OVER(), generate_series(1,2) FROM (select 1) as x(a);
a | lag | count | generate_series
---+-----+-------+-----------------
1 | | 1 | 1
1 | | 1 | 2
(2 rows)
```

Jira issue: CRDB-22398

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.