apache / apache/datafusion-sqlparser-rs

make `Parser` generic around dialect

未关闭
#1,381 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Rust
星标
3.5k
派生
772
平均合并
4 天 9 小时
30 天内合并 PR
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
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。