Skip to content

feat: optimize expressions parsing using pest Pratt parser, refactor str ->...

Emir Vildanov requested to merge optimize-expr into main

Summarize the changes

Optimize parsing of expressions using pest Pratt parser. This MR changes the previous flow of sql string -> ast -> plan creation flow in a way of separate handling of expressions:

  • First we build an AST from pest pairs (now ast build is just an internal step, which is not visible for the user)
  • We start handling them in a bottom-up manner skipping expressions
  • When handling AST node that has a child expression (e.g. Projection columns or Selection/Condition expressions) we parse those expressions with a new logic function call. We get a tree of Expressions build wit correct priorities and then populate plan

(Questionably) closes #389 (closed), #480 (closed), #544 (closed) (closed previously)

Ensure that

  • New code is covered by unit and integration tests.
  • Related issues would be automatically closed with gitlab's closing pattern (Closes #1, #2).
  • Public modules are documented (check the rendered version with cargo doc --open).
  • (if PEST grammar is changed) EBNF grammar reflects these changes (check the result with railroad diagram generator.

Next steps

Merge request reports