cockroachdb / cockroachdb/cockroach

Support WITH ORDINALITY also on VALUES clause

Ouverte
#93,704 5 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
C-enhancement O-community T-sql-foundations
Langage dominant
Go
Étoiles
32.5k
Forks
4.1k
Métriques de merge des PR
Métriques de PR en attente

Description

**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

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.