Skip to main content

Module ast

Module ast 

Source
Expand description

The GoogleSQL (BigQuery) syntax tree.

Every node derives Clone, PartialEq, Eq, Hash and serde. Equality is structural and ignores pure spelling: an identifier’s quoting and a string literal’s quote style do not take part, so `a` equals a and 'x' equals "x".

Structs§

Align
ALIGN (...): time-series alignment of an input to a regular grid of periods. The output is the PARTITION BY columns, then the METRICS, then the aligned timestamp column.
AlignMetric
One METRICS item of ALIGN.
AlterTable
Assignment
target = value in UPDATE ... SET and MERGE ... UPDATE SET; the target is a path (a.b).
BytesLiteral
CaseWhen
ColumnDef
ConditionalBlock
cond THEN statements of an IF/ELSEIF or a CASE statement’s WHEN.
CreateFunction
CreateProcedure
CreateSchema
CreateTable
CreateTableFunction
CreateView
Cte
Delete
Drop
ExportData
ExprWithAlias
An expression with an optional AS name.
Function
FunctionParam
HavingBound
HAVING MAX expr / HAVING MIN expr in an aggregate.
Ident
One identifier. quoted records whether it was written in backticks.
Insert
IntervalLiteral
INTERVAL value part [TO part].
Join
Limit
LoadData
LOAD DATA {INTO|OVERWRITE} [TEMP TABLE] name ...; the clauses after the name are kept as text.
MatchRecognize
MATCH_RECOGNIZE (...): row pattern recognition over an ordered input. BigQuery returns one row per match: the PARTITION BY columns, then the MEASURES.
Merge
MergeClause
NamedWindow
ObjectName
A dotted name: a table, routine or column path (`p.d.t`, p.d.t, SAFE.DIVIDE).
OrderByExpr
PipeExprItem
An expression item of |> AGGREGATE or its GROUP BY, with optional alias and order.
ProcedureParam
Query
A query: an optional WITH, a body, ORDER BY/LIMIT, then any pipe operators.
Select
SqlOption
name = value inside OPTIONS(...).
StringLiteral
A string or bytes literal. Equality compares the value only, not the quotes used.
StructExprField
A field of STRUCT(expr AS name) or (a, b).
StructField
A field of STRUCT<name type> or a column of TABLE<...>.
TableCopy
TableName
A table identity: project.dataset.name, with the leading parts optional.
TableSample
TableWithJoins
UnpivotColumns
Update
ViewColumn
WildcardOptions
WindowFrame
WindowSpec
With

Enums§

AfterMatchSkip
AFTER MATCH SKIP ...
AlterAction
AlterColumnAction
BinaryOperator
ControlKind
CopyKind
LIKE, COPY or CLONE a table in CREATE TABLE.
Corresponding
How a set operation lines up columns.
DataType
A GoogleSQL data type. Aliases (INT, INTEGER, DECIMAL, …) map to the canonical type.
Expr
A GoogleSQL expression.
FrameBound
FrameUnits
FunctionArg
FunctionBody
GroupBy
GroupByItem
InsertSource
JoinConstraint
JoinKind
LikePatterns
LikeQuantifier
Literal
MergeAction
MergeMatch
NullTreatment
ObjectType
ParamMode
ParamType
A routine parameter type: a data type, ANY TYPE, TABLE<...> or ANY TABLE.
Parameter
PatternQuantifier
A row pattern quantifier.
PipeOperator
RowPattern
A PATTERN of MATCH_RECOGNIZE.
SampleUnit
SelectAs
SelectItem
SetExpr
SetOpMode
FULL/LEFT/INNER before a set operator (column matching mode).
SetOperator
SetQuantifier
Statement
One GoogleSQL statement.
SubscriptKind
TableConstraint
TableFactor
TableKind
TransactionKind
UnaryOperator
WindowType

Constants§

COMPARISON_PRECEDENCE
Precedence of comparison-level predicates (IS, IN, LIKE, BETWEEN).
NOT_PRECEDENCE
Precedence of prefix NOT.
UNARY_PRECEDENCE
Precedence of unary -, +, ~.

Traits§

Visitor
Something a query walk can visit: queries, selects, expressions and table factors.

Functions§

walk_expr
Walk an expression and everything inside it (subqueries included).
walk_expr_mut
Call f on every expression inside expr, children first (so a replacement is not walked again). With into_queries, expressions of subqueries are visited too.
walk_query
Walk a query and everything inside it.
walk_query_exprs_mut
Call f on every expression of the query, subqueries and CTEs included, children first.
walk_select
Walk a select and everything inside it.
walk_statement
Walk every node of a statement, calling the visitor before descending.
walk_statement_exprs_mut
Call f on every expression a statement holds (subqueries included), children first.
walk_table_factor
Walk a table factor.
walk_table_with_joins
Walk a FROM item with its joins.