Expand description
rudb’s abstract syntax tree.
The parse tree the matcher produces is DuckDB’s grammar, faithfully. That is the point of it and
it is also why nothing downstream should read it: a bump of the vendored grammar is allowed to
rename BetweenInLikeExpression, and if the binder is matching on that name then the bump is a
rewrite. This module is the boundary. It is ours, it changes when we decide it changes, and
transform is the one place that knows both shapes.
Everything is an arena with u32 indices, per spec/04-architecture.md section 4.5. There is
no Box and no Vec inside a node. A list of children is a Slice into a side vector, which
means a node is a fixed size, the whole tree is a handful of allocations, and walking it is a
sequential read rather than a pointer chase per node. It also means an Ast is Clone and
Send without any thought, and that a subtree can be addressed by a u32 in a plan or an
error without borrowing anything.
The one cost is that you cannot hold a reference to a node and index the arena at the same time,
so the code reads a node out by value first. Nodes are small and Copy, so that is a register
move.
Structs§
- Ast
- A parsed statement or script, with every arena it points into.
- CaseArm
- One
WHEN a THEN b. - Order
Item - One entry of an order by list.
- Query
- A query: a body, plus the modifiers that apply to whatever the body produced.
- Select
- One select block.
- Slice
- A run of items in one of the side vectors.
- Target
- One entry of a target list.
Enums§
- Binary
Op - An infix operator.
- Distinct
- What the
DISTINCTclause of a select said. - Expr
- One expression.
- Join
Kind - Which join.
- Literal
Kind - Which literal.
- Nulls
- Null placement in a sort.
- Order
- Sort direction, with the unwritten case kept apart from the default it resolves to.
- Quantifier
- Whether a set operator or an aggregate keeps duplicates.
- Query
Body - What produces the rows of a query.
- SetOp
- Which set operator.
- Source
- One entry in a
FROMclause, which is a tree because joins nest. - Statement
- One statement.
- UnaryOp
- A prefix or postfix operator.