apache / apache/datafusion-sqlparser-rs

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

Aberta
#1,634 8 comentários 1 reação 0 responsáveis Ver no GitHub
Linguagem predominante
Rust
Estrelas
3.5k
Forks
772
Merge médio
4d 9h
PRs com merge (30d)
17

Descrição

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 ?

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

Nenhum arquivo ou teste específico é mencionado. Comece revisando o suporte a localização no código-fonte do AST introduzido no sqlparser v0.53 e o caminho de formatação existente; o trabalho estará concluído quando for possível reconstruir a formatação original da consulta com precisão suficiente para que as posições no código-fonte continuem significativas.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
rust, sql
Domínio
compilers
Tipo de issue
Funcionalidade
Dificuldade
5/5
Tempo estimado
Mais de uma semana
Status de atividade
Estagnada
Clareza
Precisa de esclarecimento
Facilidade para iniciantes
25/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.