apache / apache/datafusion-sqlparser-rs

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

Abierto
#1,634 8 comentarios 1 reacción 0 asignados Ver en GitHub
Lenguaje dominante
Rust
Estrellas
3.5k
Forks
772
Merge medio
4 d 9 h
PR fusionados (30 d)
17

Descripción

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 ?

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

No se nombran archivos ni pruebas específicos. Empieza revisando el soporte de localización en el código fuente del AST introducido en sqlparser v0.53 y la ruta de formateo existente; se considera terminado cuando se pueda reconstruir el formato original de la consulta con suficiente precisión para que las posiciones de origen sigan siendo significativas.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
rust, sql
Área
compilers
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.