apache / apache/datafusion-sqlparser-rs
Use identifiable structs for AST variant fields
- Lingua principale
- Rust
- Stelle
- 3.5k
- Fork
- 772
- Merge medio
- 4g 9h
- PR unite (30g)
- 17
Descrizione
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?
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia esaminando l’enum Statement e le definizioni correlate in src/ast/mod.rs, in particolare le righe collegate intorno a 490-497. Valuta come ogni campo inline di una variante potrebbe diventare una struct identificabile, preservando la forma proposta dell’AST. Il lavoro è completato quando le varianti rilevanti dell’AST utilizzano struct con nome e la conseguente modifica incompatibile dell’API viene applicata in modo coerente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rust
- Ambito
- compilers
- Tipo di issue
- Refactoring
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 25/100