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§
- Alter
ALTER TABLE name actionorALTER VIEW name RENAME TO other.- Ast
- A parsed statement or script, with every arena it points into.
- Attach
ATTACH [OR REPLACE] [IF NOT EXISTS] [DATABASE] path [AS alias] [(options)].- CaseArm
- One
WHEN a THEN b. - Column
Def - One column of a
CREATE TABLE. - Conflict
ON CONFLICT,INSERT OR REPLACEorINSERT OR IGNORE.- CopyTo
COPY ... TO, which writes what a query answers to a file.- Create
Table CREATE TABLE name (columns)orCREATE TABLE name AS query.- Create
View CREATE VIEW name (columns) AS query.- Cte
- A
WITH name AS MATERIALIZED (query), which is run once and read wherever it is named. - Drop
Table DROP TABLE a, borDROP VIEW a, b.- Index
CREATE [UNIQUE] INDEX name ON table (elements)orDROP INDEX name.- Insert
INSERT INTO name (columns) query.- Order
Item - One entry of an order by list.
- Query
- A query: a body, plus the modifiers that apply to whatever the body produced.
- Schema
CREATE SCHEMA nameorDROP SCHEMA name.- Select
- One select block.
- Sequence
CREATE SEQUENCE name optionsorDROP SEQUENCE name.- Setting
SET name = valueandRESET name.- Slice
- A run of items in one of the side vectors.
- Target
- One entry of a target list.
- TypeDef
CREATE TYPE name AS typeorDROP TYPE name.- Window
Spec - Everything inside the parentheses of an
OVER.
Enums§
- Alter
Action - What one
ALTER TABLEdoes. A column is named as written. - Binary
Op - An infix operator.
- Conflict
Action - What happens to a row whose key is already held.
- Constraint
- One constraint of a
CREATE TABLE, by its place in the list of its kind. - 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.
- Scope
- Which copy of a setting a statement means.
- SetOp
- Which set operator.
- Source
- One entry in a
FROMclause, which is a tree because joins nest. - Statement
- One statement.
- Transaction
- What a transaction statement asks for.
- UnaryOp
- A prefix or postfix operator.
- Window
Bound - One end of a window frame.
- Window
Exclude - Which peers of the current row the frame drops once its bounds have been applied.
- Window
Unit - How a window frame measures the distance to its bounds.
Type Aliases§
- Alter
Ref - Index into
Ast::alters. - Attach
Ref - An index into
Ast::attaches. - Copy
ToRef - An index into
Ast::copies. - Create
Table Ref - An index into
Ast::create_tables. - Create
View Ref - An index into
Ast::create_views. - Drop
Table Ref - An index into
Ast::drop_tables. - ExprRef
- An index into
Ast::exprs. - Index
Ref - Index into
Ast::indexes. - Insert
Ref - An index into
Ast::inserts. - Query
Ref - An index into
Ast::queries. - Schema
Ref - Index into
Ast::schemas. - Select
Ref - An index into
Ast::selects. - Sequence
Ref - Index into
Ast::sequences. - Setting
Ref - An index into
Ast::settings. - Source
Ref - An index into
Ast::sources. - StrRef
- An index into
Ast::strings. - TypeRef
- Index into
Ast::types. - Window
Ref - An index into
Ast::windows.