apache / apache/datafusion-sqlparser-rs
formatting the AST while preserving the source location information from the original query
- Langage dominant
- Rust
- Étoiles
- 3.5k
- Forks
- 772
- Merge moyen
- 4 j 9 h
- PR mergées (30 j)
- 17
Description
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 ?
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Aucun fichier ni test précis n’est indiqué. Commencez par examiner la prise en charge de la localisation dans le code source de l’AST introduite dans sqlparser v0.53 ainsi que le chemin de formatage existant ; le travail est terminé lorsque le formatage de la requête d’origine peut être reconstruit avec suffisamment de précision pour que les positions dans le code source restent pertinentes.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- rust, sql
- Domaine
- compilers
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100