apache / apache/datafusion-sqlparser-rs

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

Offen
#1,634 8 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Rust
Sterne
3.5k
Forks
772
Ø Merge
4 T. 9 Std.
Gemergte PRs (30 T.)
17

Beschreibung

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 ?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Es werden keine bestimmten Dateien oder Tests genannt. Beginne mit der Prüfung der in sqlparser v0.53 eingeführten Unterstützung für Quellpositionen im AST und des bestehenden Formatierungspfads; abgeschlossen ist die Arbeit, wenn die ursprüngliche Formatierung der Abfrage hinreichend genau rekonstruiert wird, sodass die Quellpositionen aussagekräftig bleiben.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
rust, sql
Bereich
compilers
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.