apache / apache/datafusion-sqlparser-rs
Always wrap statement in a named struct
- 主要语言
- Rust
- 星标
- 3.5k
- 派生
- 772
- 平均合并
- 4 天 9 小时
- 30 天内合并 PR
- 17
描述
In [GreptimeDB](https://github.com/GreptimeTeam/greptimedb/blob/v0.7.1/src/sql/src/statements/delete.rs), we write code like:
```rust
#[derive(Debug, Clone, PartialEq, Eq, Visit, VisitMut)]
pub struct Delete {
// Can only be sqlparser::ast::Statement::Delete variant
pub inner: Statement,
}
```
It's because in sqlparser-rs, these statement variants are unnamed struct:
```rust
Delete {
/// Multi tables delete are supported in mysql
tables: Vec,
/// FROM
from: Vec,
/// USING (Snowflake, Postgres, MySQL)
using: Option>,
/// WHERE
selection: Option,
/// RETURNING
returning: Option>,
},
```
I wonder if we can always wrap statement in a named struct so that downstream software can reuse the AST and impls (like for Display) more smoothly.
I don't know if it's a breaking change or we're generally OK with this.
Ref - https://github.com/GreptimeTeam/greptimedb/issues/3646
贡献指南
这个仓库没有索引到贡献指南
调研方向
首先检查 sqlparser AST 中的 statement 定义,以及 GreptimeDB 的 src/sql/src/statements/delete.rs 中所示的下游 wrapper。检查下游代码如何实现或使用 Display 和其他 AST trait,然后确定包装每个 statement variant 对兼容性的影响。当有一份已记录的设计或已接受的实现计划,处理复用和 breaking change 方面的考量时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- rust, sql
- 领域
- compilers
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100