apache / apache/datafusion-sqlparser-rs

make `Parser` generic around dialect

オープン
#1,381 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Rust
スター
3.5k
フォーク
772
平均マージ
4日 9時間
マージ済み PR(30日)
17

説明

if we care about performance, we should stop using dynamic dispatch and make the parser generic around the dialect, with that we could make lots of these methods `const` (or drop the `Precedence` enum and just have const values on the trait) and probably improve performance significantly in general.

That would of course be a big change to the public API.

This is definitely how would implement `Parser` if I was starting now, but I think we should see some evidence that parsing SQL is a meaningful chunk of time for anyone before making a change like this.

My guess is that:
* even for quick queries, SQL parsing is <1% of query time
* making `Parser` generic and therefore dropping the restriction on `Dialect` that it has to be 'object safe' would actually only save us ~20%

If both those assumptions are right, this doesn't seem worth it unless it makes the code generally easier to reason with and work on.

_Originally posted by @samuelcolvin in https://github.com/sqlparser-rs/sqlparser-rs/issues/1379#issuecomment-2289164242_

(separate issue seems worth it for this discussion)

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

まず Parser、Dialect、Precedence enum を調査し、SQL パースがクエリ時間の中で意味のある割合を占めるかどうかを確認します。現在の動的ディスパッチ方式をベンチマークし、汎用的な Parser 設計と比較します。パフォーマンス上の利点についての証拠が得られ、公開 API の変更方針が確定すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
rust
領域
compilers, databases
issue の種類
リファクタリング
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。