apache / apache/datafusion-sqlparser-rs
Use identifiable structs for AST variant fields
- 主要言語
- Rust
- スター
- 3.5k
- フォーク
- 772
- 平均マージ
- 4日 9時間
- マージ済み PR(30日)
- 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 付近のリンクされた行を確認してください。提案されている AST の形状を維持しながら、各 inline variant field を識別可能な struct にできるかを評価してください。関連する AST バリアントが名前付き struct を使用し、その結果生じる breaking API change が一貫して適用されていれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- rust
- 領域
- compilers
- issue の種類
- リファクタリング
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100