apache / apache/datafusion-sqlparser-rs

Use identifiable structs for AST variant fields

未關閉
#311 8 則留言 5 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
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

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。