apache / apache/datafusion-sqlparser-rs
Become more robust to parse errors
- Lenguaje dominante
- Rust
- Estrellas
- 3.5k
- Forks
- 772
- Merge medio
- 4 d 9 h
- PR fusionados (30 d)
- 17
Descripción
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.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Comienza leyendo el manejo de ParserError de sqlparser y los puntos de entrada del parser implicados al analizar `SELECT * F`; el issue no proporciona archivos ni tests específicos. Compara el comportamiento actual con los requisitos de diagnóstico de LSP y determina cómo deberían definirse un AST tolerante a errores, la compatibilidad con completion y los diagnósticos de línea/columna. Done debería incluir el comportamiento acordado y cobertura para SQL incompleto como en este ejemplo.
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