Expand description

SQL planning.

SQL planning is the process of taking the abstract syntax tree of a Statement and turning it into a Plan that the dataflow layer can execute.

Statements must be purified before they can be planned. See the pure module for details.

Modules

error 🔒
explain 🔒
This module houses a pretty printer for HirRelationExpr, which is the SQL-specific relation expression (as opposed to mz_expr::MirRelationExpr). See also mz_expr::explain.
expr 🔒
This file houses a representation of a SQL plan that is parallel to that found in src/expr/relation/mod.rs, but represents an earlier phase of planning. It’s structurally very similar to that file, with some differences which are noted below. It gets turned into that representation via a call to lower().
lowering 🔒
Lowering is the process of transforming a sql::expr::HirRelationExpr into a mz_expr::MirRelationExpr.
optimize 🔒
plan_utils 🔒
Helper code used throughout the planner.
query 🔒
SQL Querys are the declarative, computational part of SQL. This module turns Querys into HirRelationExprs - a more explicit, algebraic way of describing computation. Functions named plan_* are typically responsible for handling a single node of the SQL ast. Eg plan_query is responsible for handling sqlparser::ast::Query. plan_* functions which correspond to operations on relations typically return a HirRelationExpr. plan_* functions which correspond to operations on scalars typically return a HirScalarExpr and a ScalarType. (The latter is because it’s not always possible to infer from a HirScalarExpr what the intended type is - notably in the case of decimals where the scale/precision are encoded only in the type). Aggregates are particularly twisty.
scope 🔒
Handles SQL’s scoping rules.
statement 🔒
Statement planning.
Transformations of SQL ASTs.
Transformations of SQL IR, before decorrelation.
typeconv 🔒
Maintains a catalog of valid casts between mz_repr::ScalarTypes, as well as other cast-related functions.
Provides tooling to handle WITH options.

Structs

Generated by ALTER ... IF EXISTS if the named object did not exist.
Configuration of introspection for a compute instance.
An Explanation facilitates pretty-printing of a HirRelationExpr.
A vector of values to which parameter references should be bound.
Controls planning of a SQL query.
The state required when planning a Query.
Immutable state that applies to the planning of an entire Statement.
Describes the output of a SQL statement.

Enums

Just like MirRelationExpr, except where otherwise noted below.
Just like mz_expr::MirScalarExpr, except where otherwise noted below.
Instructions for executing a SQL query.
Specifies how long a query will live. This impacts whether the query is allowed to reason about the time at which it is running, e.g., by calling the now() function.
Specifies when a Peek or Subscribe should occur.
Settings related to storage hosts
A window function with its parameters.

Functions

Creates a description of the purified statement stmt.
Produces a Plan from the purified statement stmt.