apache / apache/datafusion-sqlparser-rs

make `Parser` generic around dialect

Offen
#1,381 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Rust
Sterne
3.5k
Forks
772
Ø Merge
4 T. 9 Std.
Gemergte PRs (30 T.)
17

Beschreibung

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)

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne mit der Untersuchung von Parser, Dialect und dem Precedence enum und ermittle anschließend, ob SQL-Parsing einen wesentlichen Teil der Abfragezeit ausmacht. Benchmarke den aktuellen Ansatz mit dynamischem Dispatch und vergleiche ihn mit einem generischen Parser-Design. Als abgeschlossen gilt die Aufgabe, wenn Belege für den Performancegewinn vorliegen und eine klare Richtung für die Änderung der öffentlichen API festgelegt ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
rust
Bereich
compilers, databases
Issue-Typ
Refactoring
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.