apache / apache/datafusion-sqlparser-rs
Eliminating whitespace from the parser logic
還沒有人認領這個 Issue。
- 主要語言
- Rust
- 星號
- 3.5k
- 分支
- 774
- 平均合併
- 4 天 9 小時
- 30 天內合併 PR
- 17
描述
Hi,
At this time, whitespace tokens are stored in the parser, and are then filtered out in several distinct points in the parser logic, such as:
* https://github.com/apache/datafusion-sqlparser-rs/blob/67684c84d4c2589356c411ea4917dcf1defcd77c/src/parser/mod.rs#L4032-L4049
* https://github.com/apache/datafusion-sqlparser-rs/blob/67684c84d4c2589356c411ea4917dcf1defcd77c/src/parser/mod.rs#L4055-L4069
* https://github.com/apache/datafusion-sqlparser-rs/blob/67684c84d4c2589356c411ea4917dcf1defcd77c/src/parser/mod.rs#L4077-L4094
* https://github.com/apache/datafusion-sqlparser-rs/blob/67684c84d4c2589356c411ea4917dcf1defcd77c/src/parser/mod.rs#L4149-L4160
* https://github.com/apache/datafusion-sqlparser-rs/blob/67684c84d4c2589356c411ea4917dcf1defcd77c/src/parser/mod.rs#L4183-L4202
and many more.
SQL, as far as I know, is not a language that cares about spaces like Python - it should be safe to remove all concepts of whitespaces after [the tokenization process](https://github.com/apache/datafusion-sqlparser-rs/blob/67684c84d4c2589356c411ea4917dcf1defcd77c/src/tokenizer.rs#L937-L942) is complete, and this should:
* Reduce memory requirements, as whitespace tokens would not be stored anymore
* Significantly simplify parser logic by removing all of the whitespace-related logic from the parser
* Move the parser closer to a streaming logic, but that will require many more PRs
Since such a PR would require quite a bit of effort on my part, I would appreciate some feedback on it before moving forward with it.
@iffyio do you happen to have any opinion regarding such a refactoring?
Ciao,
Luca
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先閱讀 src/tokenizer.rs 中連結的 tokenizer 區段,以及 src/parser/mod.rs 中的空白處理範例。追蹤空白 token 如何從 tokenization 流向 parser filtering,然後檢視相關的 parser 測試(如果找到)。當提議的空白處理重構已一致定義,且 parser 行為仍有測試涵蓋時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- rust, sql
- 領域
- compilers, databases
- Issue 類型
- 重構
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100