Module plan

Source
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 πŸ”’
EXPLAIN support for structures defined in this crate.
hir πŸ”’
This file houses HIR, a representation of a SQL plan that is parallel to MIR, but represents an earlier phase of planning. It’s structurally very similar to MIR, with some differences which are noted below. It gets turned into MIR via a call to lower().
literal πŸ”’
lowering πŸ”’
Lowering is the process of transforming a HirRelationExpr into a MirRelationExpr.
notice πŸ”’
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. E.g. 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.
side_effecting_func πŸ”’
Support for side-effecting functions.
statement πŸ”’
Statement planning.
transform_ast πŸ”’
Transformations of SQL ASTs.
transform_hir πŸ”’
Transformations of SQL IR, before decorrelation.
typeconv πŸ”’
Maintains a catalog of valid casts between mz_repr::ScalarTypes, as well as other cast-related functions.
with_options πŸ”’
Provides tooling to handle WITH options.

StructsΒ§

AbortTransactionPlan
AggregateExpr
AlterClusterPlan
AlterClusterRenamePlan
AlterClusterReplicaRenamePlan
AlterClusterSwapPlan
AlterConnectionPlan
AlterDefaultPrivilegesPlan
AlterItemRenamePlan
AlterNetworkPolicyPlan
AlterNoopPlan
Generated by ALTER ... IF EXISTS if the named object did not exist.
AlterOwnerPlan
AlterRetainHistoryPlan
AlterRolePlan
AlterSchemaRenamePlan
AlterSchemaSwapPlan
AlterSecretPlan
AlterSetClusterPlan
AlterSinkPlan
AlterSourceAddSubsourceOptionExtracted
AlterSourcePlan
AlterSystemResetAllPlan
AlterSystemResetPlan
AlterSystemSetPlan
AlterTablePlan
ClosePlan
CommentPlan
CommitTransactionPlan
ComputeReplicaConfig
ComputeReplicaIntrospectionConfig
Configuration of introspection for a cluster replica.
Connection
CopyFromPlan
CopyToPlan
CreateClusterManagedPlan
CreateClusterPlan
CreateClusterReplicaPlan
CreateClusterUnmanagedPlan
CreateConnectionPlan
CreateContinualTaskPlan
CreateDatabasePlan
CreateIndexPlan
CreateMaterializedViewPlan
CreateNetworkPolicyPlan
CreateRolePlan
CreateSchemaPlan
CreateSecretPlan
CreateSinkPlan
CreateSourcePlan
CreateSourcePlanBundle
A CreateSourcePlan and the metadata necessary to sequence it.
CreateTablePlan
CreateTypePlan
CreateViewPlan
DeallocatePlan
DeclarePlan
DropObjectsPlan
DropOwnedPlan
ExecutePlan
ExplainPlanPlan
ExplainPushdownPlan
ExplainSinkSchemaPlan
ExplainTimestampPlan
ExprContext
A bundle of unrelated things that we need for planning Exprs.
FetchPlan
GrantPrivilegesPlan
GrantRolePlan
Hir
HirToMirConfig
Index
Ingestion
InsertPlan
InspectShardPlan
MaterializedView
MySqlConfigOptionExtracted
NetworkPolicyRule
Params
A vector of values to which parameter references should be bound.
PgConfigOptionExtracted
PlanClusterOption
PlanContext
Controls planning of a SQL query.
PolicyAddress
PreparePlan
QueryContext
The state required when planning a Query.
RaisePlan
ReadThenWritePlan
ReassignOwnedPlan
ResetVariablePlan
RevokePrivilegesPlan
RevokeRolePlan
Scope
Secret
SelectPlan
A plan for select statements.
SendDiffsPlan
SetTransactionPlan
SetVariablePlan
ShowColumnsPlan
ShowCreatePlan
ShowVariablePlan
Sink
Source
SourceReference
An available external reference for a source and if possible to retrieve, any column names it contains.
SourceReferences
SqlServerConfigOptionExtracted
StartTransactionPlan
StatementContext
Immutable state that applies to the planning of an entire Statement.
StatementDesc
Describes the output of a SQL statement.
SubscribePlan
Table
Type
UpdatePrivilege
ValidateConnectionPlan
View
WebhookHeaderFilters
WebhookHeaders
WebhookValidation
WebhookValidationSecret

EnumsΒ§

AlterClusterPlanStrategy
AlterConnectionAction
AlterOptionParameter
AlterSourceAction
ClusterSchedule
CoercibleScalarExpr
A CoercibleScalarExpr is a HirScalarExpr whose type is not fully determined. Several SQL expressions can be freely coerced based upon where in the expression tree they appear. For example, the string literal β€˜42’ will be automatically coerced to the integer 42 if used in a numeric context:
ConnectionDetails
CopyFormat
CopyFromFilter
CopyFromSource
CreateClusterVariant
DataSourceDesc
ExecuteTimeout
Explainee
The type of object to be explained
ExplaineeStatement
Explainee types that are statements.
ExplaineeStatementKind
HirRelationExpr
Just like mz_expr::MirRelationExpr, except where otherwise noted below.
HirScalarExpr
Just like mz_expr::MirScalarExpr, except where otherwise noted below.
IndexOption
JoinKind
MutationKind
NetworkPolicyRuleAction
NetworkPolicyRuleDirection
OnTimeoutAction
Plan
Instructions for executing a SQL query.
PlanError
PlanKind
PlanNotice
Notices that can occur in the adapter layer.
PlannedAlterRoleOption
PlannedRoleVariable
QueryLifetime
Specifies how long a query will live.
QueryWhen
Specifies when a Peek or Subscribe should occur.
ReplicaConfig
SideEffectingFunc
A side-effecting function is a function whose evaluation triggers side effects.
SshKey
StatementClassification
Statement classification as documented by plan.
SubscribeFrom
SubscribeOutput
TableDataSource
TableOption
TransactionType
VariableValue
WebhookBodyFormat
WindowExprType
A window function with its parameters.

FunctionsΒ§

describe
Creates a description of the purified statement stmt.
normalize_subqueries
Normalize the way subqueries appear in HirScalarExpr::Exists or HirScalarExpr::Select variants.
plan
Produces a Plan from the purified statement stmt.
plan_copy_from
resolve_cluster_for_materialized_view