apache / apache/datafusion-sqlparser-rs

make `Parser` generic around dialect

Aperta
#1,381 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
3.5k
Fork
772
Merge medio
4g 9h
PR unite (30g)
17

Descrizione

if we care about performance, we should stop using dynamic dispatch and make the parser generic around the dialect, with that we could make lots of these methods `const` (or drop the `Precedence` enum and just have const values on the trait) and probably improve performance significantly in general.

That would of course be a big change to the public API.

This is definitely how would implement `Parser` if I was starting now, but I think we should see some evidence that parsing SQL is a meaningful chunk of time for anyone before making a change like this.

My guess is that:
* even for quick queries, SQL parsing is <1% of query time
* making `Parser` generic and therefore dropping the restriction on `Dialect` that it has to be 'object safe' would actually only save us ~20%

If both those assumptions are right, this doesn't seem worth it unless it makes the code generally easier to reason with and work on.

_Originally posted by @samuelcolvin in https://github.com/sqlparser-rs/sqlparser-rs/issues/1379#issuecomment-2289164242_

(separate issue seems worth it for this discussion)

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia esaminando Parser, Dialect e l’enum Precedence, quindi stabilisci se il parsing SQL costituisce una parte significativa del tempo della query. Esegui un benchmark dell’approccio attuale con dispatch dinamico e confrontalo con un design generico di Parser. Il lavoro è completato quando sono disponibili evidenze sul beneficio in termini di prestazioni e viene stabilita una direzione definitiva per la modifica dell’API pubblica.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust
Ambito
compilers, databases
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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.