Module ast

Source
Expand description

SQL Abstract Syntax Tree (AST) types

Modules§

helpers

Structs§

Array
Represents an Array Expression, either ARRAY[..], or [..]
ArrayAgg
An ARRAY_AGG invocation ARRAY_AGG( [ DISTINCT ] <expr> [ORDER BY <expr>] [LIMIT <n>] ) Or ARRAY_AGG( [ DISTINCT ] <expr> ) [ WITHIN GROUP ( ORDER BY <expr> ) ] ORDER BY position is defined differently for BigQuery, Postgres and Snowflake.
Assignment
SQL assignment foo = expr as used in SQLUpdate
ColumnDef
SQL column definition
ColumnOptionDef
An optionally-named ColumnOption: [ CONSTRAINT <name> ] <column-option>.
ConstraintCharacteristics
<constraint_characteristics> = [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] [ ENFORCED | NOT ENFORCED ]
CreateFunctionBody
Postgres specific feature.
Cte
A single CTE (used after WITH): alias [(col1, col2, ...)] AS ( query ) The names in the column list before AS, when specified, replace the names of the columns returned by the query. The parser does not validate that the number of columns in the query matches the number of columns in the query.
DoUpdate
DollarQuotedString
DropFunctionDesc
Function describe in DROP FUNCTION.
ExceptSelectItem
Bigquery EXCEPT information, with at least one column.
Fetch
Function
A function call
HiveFormat
Ident
An identifier, decomposed into its value or character data and the quote style.
IdentWithAlias
Single aliased identifier
Interval
Represents an INTERVAL expression, roughly in the following format: INTERVAL '<value>' [ <leading_field> [ (<leading_precision>) ] ] [ TO <last_field> [ (<fractional_seconds_precision>) ] ], e.g. INTERVAL '123:45.67' MINUTE(3) TO SECOND(2).
Join
JsonTableColumn
A single column definition in MySQL’s JSON_TABLE table valued function.
LateralView
A hive LATERAL VIEW with potential column aliases
ListAgg
A LISTAGG invocation LISTAGG( [ DISTINCT ] <expr>[, <separator> ] [ON OVERFLOW <on_overflow>] ) ) [ WITHIN GROUP (ORDER BY <within_group1>[, ...] ) ]
LockClause
LockTable
MacroArg
NAME = <EXPR> arguments for DuckDB macros
NamedWindowDefinition
ObjectName
A name of a table, view, custom type, etc., possibly multi-part, i.e. db.schema.obj
Offset
OnConflict
OperateFunctionArg
Function argument in CREATE OR DROP FUNCTION.
OrderByExpr
An ORDER BY expression
Partition
PARTITION statement used in ALTER TABLE et al. such as in Hive SQL
ProcedureParam
Query
The most complete variant of a SELECT query expression, optionally including WITH, UNION / other set operations, and ORDER BY.
ReplaceSelectElement
Syntax
ReplaceSelectItem
Bigquery REPLACE information.
Select
A restricted variant of SELECT (without CTEs/ORDER BY), which may appear either as the only body item of a Query, or as an operand to a set operation like UNION.
SelectInto
SqlOption
StructField
A field definition within a struct.
Table
A TABLE command
TableAlias
TableWithJoins
Top
UserDefinedTypeCompositeAttributeDef
SQL user defined type attribute definition
Values
ViewColumnDef
Column definition specified in a CREATE VIEW statement.
WildcardAdditionalOptions
Additional options for wildcards, e.g. Snowflake EXCLUDE/RENAME and Bigquery EXCEPT.
WindowFrame
Specifies the data processed by a window function, e.g. RANGE UNBOUNDED PRECEDING or ROWS BETWEEN 5 PRECEDING AND CURRENT ROW.
WindowSpec
A window specification (i.e. OVER (PARTITION BY .. ORDER BY .. etc.))
With

Enums§

Action
A privilege on a database object (table, sequence, etc.).
AddDropSync
AlterColumnOperation
An ALTER COLUMN (Statement::AlterTable) operation
AlterIndexOperation
AlterRoleOperation
An ALTER ROLE (Statement::AlterRole) operation
AlterTableOperation
An ALTER TABLE (Statement::AlterTable) operation
AnalyzeFormat
ArgMode
The mode of an argument in CREATE FUNCTION.
ArrayElemTypeDef
Represents the data type of the elements in an array (if any) as well as the syntax used to declare the array.
BinaryOperator
Binary operators
CastFormat
Options for CAST / TRY_CAST BigQuery: https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#formatting_syntax
CharLengthUnits
Possible units for characters, initially based on 2016 ANSI standard.
CharacterLength
Information about character length, including length and possibly unit.
CloseCursor
ColumnOption
ColumnOptions are modifiers that follow a column definition in a CREATE TABLE statement.
CommentObject
ConflictTarget
ContextModifier
Optional context modifier for statements that can be or LOCAL, or SESSION.
CopyLegacyCsvOption
A CSV option in COPY statement before PostgreSQL version 9.0.
CopyLegacyOption
An option in COPY statement before PostgreSQL version 9.0.
CopyOption
An option in COPY statement.
CopySource
CopyTarget
CreateFunctionUsing
CreateTableOptions
Sql options of a CREATE TABLE statement.
DataType
SQL data types
DateTimeField
DeferrableInitial
DiscardObject
Distinct
DropFunctionOption
Function describe in DROP FUNCTION.
ExactNumberInfo
Additional information for NUMERIC, DECIMAL, and DEC data types following the 2016 standard.
ExcludeSelectItem
Snowflake EXCLUDE information.
Expr
An SQL expression of any type.
FetchDirection
Specific direction for FETCH statement
FileFormat
External table’s available file format
FlushLocation
FlushType
ForClause
FOR XML or FOR JSON clause, specific to MSSQL (formats the output of a query as XML or JSON)
ForJson
ForXml
FunctionArg
FunctionArgExpr
FunctionBehavior
These attributes inform the query optimizer about the behavior of the function.
FunctionDefinition
GeneratedAs
GeneratedAss are modifiers that follow a column option in a generated. ‘ExpStored’ is used for a column generated from an expression and stored.
GeneratedExpressionMode
GeneratedExpressionModes are modifiers that follow an expression in a generated. No modifier is typically the same as Virtual.
GrantObjects
Objects on which privileges are granted in a GRANT statement.
GroupByExpr
HiveDistributionStyle
HiveIOFormat
HiveRowFormat
IndexType
Indexing method used by that index.
JoinConstraint
JoinOperator
JsonOperator
JsonOperator
JsonTableColumnErrorHandling
Stores the error handling clause of a JSON_TABLE table valued function: {NULL | DEFAULT json_string | ERROR} ON {ERROR | EMPTY }
KeyOrIndexDisplay
Representation whether a definition can can contains the KEY or INDEX keywords with the same meaning.
KillType
ListAggOnOverflow
The ON OVERFLOW clause of a LISTAGG invocation
LockTableType
LockType
MacroDefinition
MergeClause
MinMaxValue
Can use to describe options in create sequence or table column type identity [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ]
MysqlInsertPriority
Mysql specific syntax
NonBlock
NullTreatment
Specifies Ignore / Respect NULL within window functions. For example FIRST_VALUE(column2) IGNORE NULLS OVER (PARTITION BY column1)
ObjectType
OffsetRows
Stores the keyword after OFFSET <number>
OnCommit
OnConflictAction
OnInsert
Password
Privileges
Privileges granted in a GRANT statement or revoked in a REVOKE statement.
ReferentialAction
<referential_action> = { RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT }
RenameSelectItem
Snowflake RENAME information.
ResetConfig
RESET config option:
RoleOption
An option in ROLE statement.
SchemaName
Schema possible naming variants (1).
SearchModifier
Fulltext search modifiers (1).
SelectItem
One item of the comma-separated list following SELECT
SequenceOptions
Can use to describe options in create sequence or table column type identity
SetConfigValue
SET config value option:
SetExpr
A node in a tree, representing a “query body” expression, roughly: SELECT ... [ {UNION|EXCEPT|INTERSECT} SELECT ...]
SetOperator
SetQuantifier
A quantifier for SetOperator.
ShowCreateObject
ShowStatementFilter
SqliteOnConflict
Sqlite specific syntax
Statement
A top-level statement (SELECT, INSERT, CREATE, etc.)
TableConstraint
A table-level constraint, specified in a CREATE TABLE or an ALTER TABLE ADD <constraint> statement.
TableFactor
A table name or a parenthesized subquery with an optional alias
TableVersion
TimezoneInfo
Timestamp and Time data types information about TimeZone formatting.
TopQuantity
TransactionAccessMode
TransactionIsolationLevel
TransactionMode
TransactionModifier
SQLite specific syntax
TrimWhereField
UnaryOperator
Unary operators
UserDefinedTypeRepresentation
SQL user defined type definition
Value
Primitive SQL values such as number and string
WindowFrameBound
Specifies WindowFrame’s start_bound and end_bound
WindowFrameUnits
WindowType

Traits§

Visit
A type that can be visited by a Visitor. See Visitor for recursively visiting parsed SQL statements.
VisitMut
A type that can be visited by a VisitorMut. See VisitorMut for recursively visiting parsed SQL statements.
Visitor
A visitor that can be used to walk an AST tree.
VisitorMut
A visitor that can be used to mutate an AST tree.

Functions§

escape_quoted_string
visit_expressions
Invokes the provided closure on all expressions (e.g. 1 + 2) present in v
visit_expressions_mut
Invokes the provided closure iteratively with a mutable reference to all expressions present in v.
visit_relations
Invokes the provided closure on all relations (e.g. table names) present in v
visit_relations_mut
Invokes the provided closure with a mutable reference to all relations (e.g. table names) present in v.
visit_statements
Invokes the provided closure iteratively with a mutable reference to all statements present in v (e.g. SELECT, CREATE TABLE, etc).
visit_statements_mut
Invokes the provided closure on all statements (e.g. SELECT, CREATE TABLE, etc) present in v