apache / apache/datafusion-sqlparser-rs
Use identifiable structs for AST variant fields
- 主要语言
- Rust
- 星标
- 3.5k
- 派生
- 772
- 平均合并
- 4 天 9 小时
- 30 天内合并 PR
- 17
描述
When consuming the generated AST for further processing, one needs to match against and deconstruct `ast::Statement` instances. Currently, the fields of this enum's variants are defined inline... which makes it impossible for downstream code to represent the nested structures as types. For example, consider this structure:
https://github.com/ballista-compute/sqlparser-rs/blob/35ef0eee3857c59827b2587bc813218a00dce264/src/ast/mod.rs#L490-L497
I propose we migrate to the following pattern.
```rust
pub struct AnalyzeStatement {
table_name: ObjectName,
partitions: Option>,
for_columns: bool,
....
}
pub enum Statement {
Analyze(AnalyzeStatement),
...
}
```
Obviously this is a massive breaking change, but that seems OK given the `0.9.x` crates.io version.
Thoughts?
贡献指南
这个仓库没有索引到贡献指南
调研方向
首先查看 src/ast/mod.rs 中的 Statement enum 及相关定义,尤其是 490-497 附近链接的行。评估如何将每个 inline variant field 转换为可识别的 struct,同时保留所提议的 AST 形状。完成标准是相关的 AST variant 使用命名 struct,并且由此产生的 breaking API change 得到一致应用。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- rust
- 领域
- compilers
- Issue 类型
- 重构
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100