apache / apache/datafusion-sqlparser-rs

Become more robust to parse errors

Aberta
#672 1 comentário 0 reações 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

I've started working on a sql [lsp server implementation](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/), using `sqlparser` as the parser. Unfortunately, I very quickly hit a wall, mostly around how `sqlparser` discovers and surfaces errors. For instance, let's say the user types the following: `SELECT * F` and hits the key. A good lsp server would suggest completing `F` to `FROM`, even just do it automatically in that case. If one tries to parse that input string with `sqlparser`, it returns a `ParserError("Expected end of statement, found: F")`. The error isn't unexpected, but now (a) since the ast isn't available in the face of errors, there are no recommendations/commands/lints I can make based on a error-prone AST, and (b) I don't have enough information (line/col info) to send a diagnostic (the thing that makes the red squiggly lines) to the client. The line/col information was suggested in #179, but a fair amount of the work that would enable a really good LSP server implementation is being able to work with an AST that has errors in it.

I _suspect_ what I'm describing is _really_ hard, and has all sorts of backwards-incompatible changes that would be required to make this work. I think it'd be worthwhile, though.

Guia de contribuição

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

Direção de pesquisa

Comece lendo o tratamento de ParserError do sqlparser e os pontos de entrada do parser envolvidos ao analisar `SELECT * F`; a issue não fornece arquivos ou testes específicos. Compare o comportamento atual com os requisitos de diagnóstico do LSP e determine como uma AST tolerante a erros, o suporte a completion e os diagnósticos de linha/coluna devem ser definidos. Done deve incluir o comportamento acordado e a cobertura para SQL incompleto como neste exemplo.

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.