sql: DISTINCT ON a computed key fails with ORDER BY ... NULLS LAST (v26.2 regression)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 56/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Ambito
- backend-api-design, databases
Direzione di ricerca
Start in SQL optimization around buildOrderByPreProjection, identified in the issue as a likely cause, and trace how computed ORDER BY columns are projected when NULLS ordering is explicit. Compare that path with how the DISTINCT ON key’s projection is matched. Reproduce with the supplied SQL and verify it succeeds while the listed plain-column, default-order, and subquery cases continue to work.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the problem
Since v26.2.0-alpha.2, DISTINCT ON over a computed key errors when a later ORDER BY column has non-default NULLS ordering. v26.1 and Postgres accept the query.
To Reproduce
CREATE TABLE t (a INT, b INT);
INSERT INTO t VALUES (1, NULL), (1, 2), (2, 3);
SELECT DISTINCT ON (k) a + 1 AS k, b FROM t ORDER BY k, b NULLS LAST;
ERROR: SELECT DISTINCT ON expressions must match initial ORDER BY expressions
SQLSTATE: 42P10
These still work: a plain-column key (DISTINCT ON (a) ... ORDER BY a, b NULLS LAST), default NULLS order (ORDER BY k, b), or computing the key in a subquery.
Expected behavior
v26.1.8 returns:
k | b
----+----
2 | 2
3 | 3
Additional data
| Version | Result |
|---|---|
| v25.4.16, v26.1.0, v26.1.8, v26.2.0-alpha.1 | OK |
| v26.2.0-alpha.2, v26.2.0, v26.2.11, v26.3.5, v26.4.0-rc.1 | 42P10 |
The likely cause is 35c5a88b3582 (sql/opt: support subqueries in ORDER BY with NULLS FIRST/LAST, #129956). With non-default NULLS ordering, buildOrderByPreProjection appears to move computed ORDER BY columns to new pre-projected IDs, so they no longer match the DISTINCT ON key's projection column.
Environment:
- CockroachDB v26.2.11, v26.3.5 and v26.4.0-rc.1 (official darwin arm64 binaries,
start-single-node) - Client:
cockroach sql
Jira issue: CRDB-71580
- Lingua principale
- Go
- Stelle
- 32.6k
- Fork
- 4.2k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cockroachdb/cockroach
-
C-bug O-community X-blathers-untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
cockroachdb/cockroach#176245 · 1 commento ·
-
sql: pg_database.dattablespace is 0 but pg_tablespace.oid is 1663, so they no longer joinForse già presa @1AbdullahButt l’ha presa 14 giorni fa. ApertaC-bug O-community X-blathers-triaged X-move-internal
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
cockroachdb/cockroach#176228 · 1 commento ·
-
PG compat: overflow in integer power calculation triggers incompatible SQLSTATEForse di nuovo libera @darshpatel1052 l’ha presa 18 giorni fa e non c’è nessuna pull request aperta. ApertaC-bug O-community X-blathers-untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
cockroachdb/cockroach#176223 · 2 commenti ·
-
util/log: bufferedSinkCloser.Close leaks a goroutine after timeoutForse già presa @dajiaohuang l’ha presa 14 giorni fa. ApertaC-bug O-community X-blathers-untriaged
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
cockroachdb/cockroach#176210 · 1 commento ·
-
C-bug O-community T-sql-queries X-blathers-triaged X-move-internal
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
cockroachdb/cockroach#176150 · 1 commento ·
Tutte le issue di cockroachdb/cockroach
Issue simili
-
☢️ Bug v3
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
area/import-export area/projects concern/ux
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
go-vikunja/vikunja#4455 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Dependabot PRs no longer merge automaticallyForse già presa @dwisiswant0 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
projectdiscovery/urlfinder#160 ·
I maintainer di solito rispondono entro 1 giorno
-
database
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
chnm/legal-modernism#450 ·
I maintainer di solito rispondono entro 1 giorno
-
tech-debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno