apache / apache/datafusion-sqlparser-rs
Become more robust to parse errors
- 主要語言
- Rust
- 星號
- 3.5k
- 分支
- 772
- 平均合併
- 4 天 9 小時
- 30 天內合併 PR
- 17
描述
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.
貢獻指南
這個儲存庫沒有索引到貢獻指南
研究方向
首先閱讀 sqlparser 的 ParserError 處理,以及解析 `SELECT * F` 時涉及的 parser 入口點;issue 未提供具體檔案或測試。將目前行為與 LSP 診斷需求進行比較,並確定應如何定義容錯 AST、completion 支援以及行/列診斷。Done 應包括已達成共識的行為,以及對此範例這類不完整 SQL 的覆蓋。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- rust, sql
- 領域
- compilers
- Issue 類型
- 功能
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100