apache / apache/datafusion-sqlparser-rs

formatting the AST while preserving the source location information from the original query

Aperta
#1,634 8 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
3.5k
Fork
772
Merge medio
4g 9h
PR unite (30g)
17

Descrizione

In the current sqlparser, parsing

```sql
select
a,
b
from
t
```

and then fromatting it back to a string results in

```sql
select a,b from t
```

Since sqlparser v0.53, we have the source location information inside the AST, which theoretically makes it possible to reconstruct the original query formatting (or at least getting very close to it).

I know this is a huge undertaking, but it would be really useful. For instance, in [sqlpage](https://github.com/lovasoa/SQLpage), I would love being able to respect the initial user formatting of queries, in order for database errors that contain source position information to be meaningful and not confusing.

I'm opening this issue to start discussing this with the community (and especially with you @iffyio and @alamb :wink: ).

Am I the only one interested in this ? What would be the best approach to implementing this ?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Non sono indicati file o test specifici. Inizia esaminando il supporto alle posizioni nel sorgente dell’AST introdotto in sqlparser v0.53 e il percorso di formattazione esistente; il lavoro è completato quando la formattazione della query originale può essere ricostruita con una precisione sufficiente a mantenere significative le posizioni nel sorgente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust, sql
Ambito
compilers
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.