cockroachdb / cockroachdb/cockroach

Support WITH ORDINALITY also on VALUES clause

Aperta
#93,704 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub
C-enhancement O-community T-sql-foundations
Lingua principale
Go
Stelle
32.5k
Fork
4.1k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

**Describe the solution you'd like**

I've noticed that I can place `WITH ORDINALITY` almost anywhere on a table expression:
https://www.cockroachlabs.com/docs/stable/table-expressions.html

image

It even works for standalone [`table_clause`](https://www.cockroachlabs.com/docs/stable/sql-grammar.html#table_clause):

```sql
create view v as select 'a' a;
table v with ordinality;
```

Producing:

```
|a |ordinality|
|---|----------|
|a |1 |
```

Or also:

```sql
select * from (table v with ordinality);
```

But it doesn't work for the standalone [`values_clause`](https://www.cockroachlabs.com/docs/stable/sql-grammar.html#values_clause):

I.e. this doesn't work:

```sql
values ('a') with ordinality;
```

I have to do this, instead:

```sql
select * from (values ('a')) with ordinality;
```

I wonder if this is just an oversight? It's probably rarely useful, but seems to be a reasonable change from a consistency perspective?

**Additional context**

As a side note, I wonder if this improved `WITH ORDINALITY` support is worth mentioning here: https://www.cockroachlabs.com/docs/stable/postgresql-compatibility.html

Jira issue: CRDB-22489

Epic CRDB-60820

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.