cockroachdb / cockroachdb/cockroach

sql: null_ordered_last does not produce correct results with tuples

Abierto
#93,558 0 comentarios 0 reacciones 0 asignados Ver en GitHub
A-sql-pgcompat C-bug docs-done docs-known-limitation T-sql-queries
Lenguaje dominante
Go
Estrellas
32.5k
Forks
4.1k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

**Describe the problem**

By default, CockroachDB orders NULLs before all other values. For compatibility with Postgres, we added a session setting, `null_ordered_last`, which changes the default to order NULLs after all other values. This works in most cases, thanks to some transformations we make in the optimizer to add extra ordering columns. However, it is broken when the ordering column is a tuple.

**To Reproduce**

On `./cockroach demo`, on master (23.1 alpha), run the following:
```
SET null_ordered_last = true;

WITH t (x, y) AS (
VALUES
((1, 1), 1),
((NULL::RECORD), 2),
((1, NULL::INT), 3),
((NULL::INT, NULL::INT), 4)
)
SELECT *
FROM t
ORDER BY x;
```
The result on CockorachDB:
```
x | y
--------+----
(1,) | 3
(1,1) | 1
NULL | 2
(,) | 4
```
The result on Postgres:
```
x | y
-------+---
(1,1) | 1
(1,) | 3
(,) | 4
| 2
```

**Expected behavior**
The CockroachDB output should match Postgres when `null_ordered_last` is true.

**Environment:**
- CockroachDB version: v23.1.0-alpha....dirty
- Server OS: macOS Monterey
- Client app: cockroach demo

Jira issue: CRDB-22400

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.