Expand description
SQL Abstract Syntax Tree (AST) types
Modules§
Structs§
- Array
- Represents an Array Expression, either
ARRAY[..], or[..] - Assignment
- SQL assignment
foo = expras used in SQLUpdate - Clustered
By - Hive supports
CLUSTERED BYstatement inCREATE TABLE. Syntax:CLUSTERED BY (col_name, ...) [SORTED BY (col_name [ASC|DESC], ...)] INTO num_buckets BUCKETS - Clustered
Index - Column
Def - SQL column definition
- Column
Option Def - An optionally-named
ColumnOption:[ CONSTRAINT <name> ] <column-option>. - Column
Policy Property - Connect
By - Joins a table to itself to process hierarchical data in the table.
- Constraint
Characteristics <constraint_characteristics> = [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] [ ENFORCED | NOT ENFORCED ]- Create
Function - Create
Index - CREATE INDEX statement.
- Create
Table - CREATE TABLE statement.
- Cte
- A single CTE (used after
WITH):<alias> [(col1, col2, ...)] AS <materialized> ( <query> )The names in the column list beforeAS, 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. - Declare
- A
DECLAREstatement. Postgres Snowflake BigQuery - Delete
- DELETE statement.
- Dictionary
Field - A dictionary field within a dictionary.
- Display
Separated - DoUpdate
- Dollar
Quoted String - Except
Select Item - Bigquery
EXCEPTinformation, with at least one column. - Expr
With Alias - An expression optionally followed by an alias.
- Fetch
- Function
- A function call
- Function
Argument List - This represents everything inside the parentheses when calling a function.
- Function
Desc - Generic function description for DROP FUNCTION and CREATE TRIGGER.
- Having
Bound - The
HAVINGclause in a call toANY_VALUEon BigQuery. - Hive
Format - Hive
Load Data Format - Hive
RowDelimiter - Hive
SetLocation - Ident
- An identifier, decomposed into its value or character data and the quote style.
- Ident
With Alias - Single aliased identifier
- Identity
Parameters - Identity
Property - Ilike
Select Item - Snowflake
ILIKEinformation. - Insert
- INSERT statement.
- Insert
Aliases - Interpolate
- Interpolate
Expr - ClickHouse
INTERPOLATEclause for use inORDER BYclause when usingWITH FILLmodifier. Supported by ClickHouse syntax - 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
- Json
Path - A JSON path.
- Json
Table Named Column - A single column definition in MySQL’s
JSON_TABLEtable valued function. - Json
Table Nested Column - A nested column in a JSON_TABLE column list
- Lambda
Function - A lambda function.
- Lateral
View - A hive LATERAL VIEW with potential column aliases
- Lock
Clause - Lock
Table - Macro
Arg NAME = <EXPR>arguments for DuckDB macros- Map
- Represents a Map expression.
- MapAccess
Key - Expression used to access a value in a nested structure.
- MapEntry
- A map field within a map.
- Measure
- An item in the
MEASURESsubclause of aMATCH_RECOGNIZEoperation. - Merge
Clause - A when clause within a
MERGEStatement - Merge
Insert Expr - The expression used to insert rows within a
MERGEstatement. - Method
- A method call
- Named
Window Definition - Object
Name - A name of a table, view, custom type, etc., possibly multi-part, i.e. db.schema.obj
- Offset
- OnConflict
- OneOr
Many With Parens Into Iter - Owned iterator implementation of
OneOrManyWithParens - Open
Json Table Column - A single column definition in MSSQL’s
OPENJSON WITHclause. - Operate
Function Arg - Function argument in CREATE OR DROP FUNCTION.
- OrderBy
- Order
ByExpr - An
ORDER BYexpression - Procedure
Param - Projection
Select - Query syntax for ClickHouse ADD PROJECTION statement.
Its syntax is similar to SELECT statement, but it is used to add a new projection to a table.
Syntax is
SELECT <COLUMN LIST EXPR> [GROUP BY] [ORDER BY] - Query
- The most complete variant of a
SELECTquery expression, optionally includingWITH,UNION/ other set operations, andORDER BY. - Replace
Select Element - Syntax
- Replace
Select Item - Bigquery
REPLACEinformation. - RowAccess
Policy - Snowflake
WITH ROW ACCESS POLICY policy_name ON (identifier, ...) - Secret
Option - Select
- A restricted variant of
SELECT(without CTEs/ORDER BY), which may appear either as the only body item of aQuery, or as an operand to a set operation likeUNION. - Select
Into - Setting
- Show
Statement In - Show
Statement Options - Represents the different options available for
SHOWstatements to filter the results. Example from Snowflake: https://docs.snowflake.com/en/sql-reference/sql/show-tables - Struct
Field - A field definition within a struct
- Symbol
Definition - A symbol defined in a
MATCH_RECOGNIZEoperation. - Table
- A
TABLEcommand - Table
Alias - Table
Alias Column Def - SQL column definition in a table expression alias. Most of the time, the data type is not specified. But some table-valued functions do require specifying the data type.
- Table
Engine - Engine of DB. Some warehouse has parameters of engine, e.g. clickhouse
- Table
Function Args - Arguments to a table-valued function
- Table
With Joins - Tag
- Snowflake
WITH TAG ( tag_name = '<tag_value>', ...) - Tags
Column Option - Tags option of column Syntax
- Top
- Trigger
Exec Body - This keyword immediately precedes the declaration of one or two relation names that provide access to the transition relations of the triggering statement
- Trigger
Referencing - This keyword immediately precedes the declaration of one or two relation names that provide access to the transition relations of the triggering statement
- Truncate
Table Target - Target of a
TRUNCATE TABLEcommand - Union
Field - A field definition within a union
- User
Defined Type Composite Attribute Def - SQL user defined type attribute definition
- Utility
Option - Represents a single PostgreSQL utility option.
- Values
- View
Column Def - Column definition specified in a
CREATE VIEWstatement. - Wildcard
Additional Options - Additional options for wildcards, e.g. Snowflake
EXCLUDE/RENAMEand BigqueryEXCEPT. - Window
Frame - Specifies the data processed by a window function, e.g.
RANGE UNBOUNDED PRECEDINGorROWS BETWEEN 5 PRECEDING AND CURRENT ROW. - Window
Spec - A window specification (i.e.
OVER ([window_name] PARTITION BY .. ORDER BY .. etc.)) - With
- With
Fill - ClickHouse
WITH FILLmodifier forORDER BYclause. Supported by ClickHouse syntax
Enums§
- Action
- A privilege on a database object (table, sequence, etc.).
- AddDrop
Sync - After
Match Skip - The after match skip option in a
MATCH_RECOGNIZEoperation. - Alter
Column Operation - An
ALTER COLUMN(Statement::AlterTable) operation - Alter
Index Operation - Alter
Policy Operation - An
ALTER Policy(Statement::AlterPolicy) operation - Alter
Role Operation - An
ALTER ROLE(Statement::AlterRole) operation - Alter
Table Operation - An
ALTER TABLE(Statement::AlterTable) operation - Analyze
Format - ArgMode
- The mode of an argument in CREATE FUNCTION.
- Array
Elem Type Def - Represents the data type of the elements in an array (if any) as well as the syntax used to declare the array.
- Assignment
Target - Left-hand side of an assignment in an UPDATE statement,
e.g.
fooinfoo = 5(ColumnName assignment) or(a, b)in(a, b) = (1, 2)(Tuple assignment). - Attach
DuckDB Database Option - Begin
Transaction Kind - Transaction started with [ TRANSACTION | WORK ]
- Binary
Operator - Binary operators
- Cast
Format - Options for
CAST/TRY_CASTBigQuery: https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#formatting_syntax - Cast
Kind - The syntax used for in a cast expression.
- Ceil
Floor Kind - The syntax used in a CEIL or FLOOR expression.
- Char
Length Units - Possible units for characters, initially based on 2016 ANSI standard.
- Character
Length - Information about character length, including length and possibly unit.
- Close
Cursor - Column
Option ColumnOptions are modifiers that follow a column definition in aCREATE TABLEstatement.- Column
Policy - Column policy that identify a security policy of access to a column. Syntax
- Comment
Def - Helper to indicate if a comment includes the
=in the display form - Comment
Object - Conflict
Target - Context
Modifier - Optional context modifier for statements that can be or
LOCAL, orSESSION. - Copy
Legacy CsvOption - A
CSVoption inCOPYstatement before PostgreSQL version 9.0. - Copy
Legacy Option - An option in
COPYstatement before PostgreSQL version 9.0. - Copy
Option - An option in
COPYstatement. - Copy
Source - Copy
Target - Create
Function Body - Represent the expression body of a
CREATE FUNCTIONstatement as well as where within the statement, the body shows up. - Create
Function Using - Create
Policy Command - Policy command for a
CREATE POLICYstatement. - Create
Policy Type - Policy type for a
CREATE POLICYstatement. - Create
Table Options - Sql options of a
CREATE TABLEstatement. - CteAs
Materialized - Data
Type - SQL data types
- Date
Time Field - Declare
Assignment - Represents an expression assignment within a variable
DECLAREstatement. - Declare
Type - Represents the type of a
DECLAREstatement. - Deduplicate
- DEDUPLICATE statement used in OPTIMIZE TABLE et al. such as in ClickHouse SQL ClickHouse
- Deferrable
Initial - Describe
Alias - Discard
Object - Distinct
- Drop
Function Option - Function describe in DROP FUNCTION.
- Duplicate
Treatment - Empty
Matches Mode - Enum
Member - Exact
Number Info - Additional information for
NUMERIC,DECIMAL, andDECdata types following the 2016 standard. - Exclude
Select Item - Snowflake
EXCLUDEinformation. - Expr
- An SQL expression of any type.
- Extract
Syntax EXTRACTsyntax variants.- Fetch
Direction - Specific direction for FETCH statement
- File
Format - External table’s available file format
- Flush
Location - Flush
Type - ForClause
- FOR XML or FOR JSON clause, specific to MSSQL (formats the output of a query as XML or JSON)
- ForJson
- ForXml
- Format
Clause - FORMAT identifier or FORMAT NULL clause, specific to ClickHouse.
- From
Table - A
FROMclause within aDELETEstatement. - Function
Arg - Function
ArgExpr - Function
ArgOperator - Operator used to separate function arguments
- Function
Argument Clause - Function
Arguments - The arguments passed to a function call.
- Function
Behavior - These attributes inform the query optimizer about the behavior of the function.
- Function
Called OnNull - These attributes describe the behavior of the function when called with a null argument.
- Function
Determinism Specifier - BigQuery Determinism specifier used in a UDF definition.
- Function
Parallel - If it is safe for PostgreSQL to call the function from multiple threads at once
- Generated
As GeneratedAss are modifiers that follow a column option in agenerated. ‘ExpStored’ is used for a column generated from an expression and stored.- Generated
Expression Mode GeneratedExpressionModes are modifiers that follow an expression in agenerated. No modifier is typically the same as Virtual.- Grant
Objects - Objects on which privileges are granted in a GRANT statement.
- Group
ByExpr - Group
ByWith Modifier - ClickHouse supports GROUP BY WITH modifiers(includes ROLLUP|CUBE|TOTALS). e.g. GROUP BY year WITH ROLLUP WITH TOTALS
- Having
Bound Kind - Hive
Delimiter - Hive
Describe Format - Hive
Distribution Style - HiveIO
Format - Hive
RowFormat - Identity
Property Format Kind - A format of parameters of identity column.
- Identity
Property Kind - Identity is a column option for defining an identity or autoincrement column in a
CREATE TABLEstatement. Syntax - Identity
Property Order - The identity column option specifies how values are generated for the auto-incremented column, either in increasing or decreasing order. Syntax
- Index
Option - MySQLs index option.
- Index
Type - Indexing method used by that index.
- Join
Constraint - Join
Operator - Json
Null Clause - MSSQL’s json null clause
- Json
Path Elem - An element of a JSON path.
- Json
Table Column - A single column definition in MySQL’s
JSON_TABLEtable valued function. - Json
Table Column Error Handling - Stores the error handling clause of a
JSON_TABLEtable valued function: {NULL | DEFAULT json_string | ERROR} ON {ERROR | EMPTY } - KeyOr
Index Display - Representation whether a definition can can contains the KEY or INDEX keywords with the same meaning.
- Kill
Type - List
AggOn Overflow - The
ON OVERFLOWclause of a LISTAGG invocation - Lock
Table Type - Lock
Type - Macro
Definition - MapAccess
Syntax - Represents the syntax/style used in a map access.
- Match
Recognize Pattern - The pattern in a
MATCH_RECOGNIZEoperation. - Match
Recognize Symbol - A symbol in a
MATCH_RECOGNIZEpattern. - Merge
Action - Underlying statement of a when clause within a
MERGEStatement - Merge
Clause Kind - Variant of
WHENclause used within aMERGEStatement. - Merge
Insert Kind - The type of expression used to insert rows within a
MERGEstatement. - MinMax
Value - Can use to describe options in create sequence or table column type identity [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ]
- MySQL
Column Position - MySQL
ALTER TABLEonly [FIRST | AFTER column_name] - Mysql
Insert Priority - Mysql specific syntax
- Named
Window Expr - An expression used in a named window declaration.
- NonBlock
- Null
Treatment - Specifies Ignore / Respect NULL within window functions.
For example
FIRST_VALUE(column2) IGNORE NULLS OVER (PARTITION BY column1) - Nulls
Distinct Option - Postgres unique index nulls handling option:
[ NULLS [ NOT ] DISTINCT ] - Object
Type - Offset
Rows - Stores the keyword after
OFFSET <number> - OnCommit
- OnConflict
Action - OnInsert
- OneOr
Many With Parens - Encapsulates the common pattern in SQL where either one unparenthesized item
such as an identifier or expression is permitted, or multiple of the same
item in a parenthesized list. For accessing items regardless of the form,
OneOrManyWithParensimplementsDeref<Target = [T]>andIntoIterator, so you can call slice methods on it and iterate over items - Owner
- Partition
- PARTITION statement used in ALTER TABLE et al. such as in Hive and ClickHouse SQL. For example, ClickHouse’s OPTIMIZE TABLE supports syntax like PARTITION ID ‘partition_id’ and PARTITION expr. ClickHouse
- Partition
Range Direction - Specifies which partition the boundary values on table partitioning belongs to.
- Password
- Pivot
Value Source - The source of values in a
PIVOToperation. - Privileges
- Privileges granted in a GRANT statement or revoked in a REVOKE statement.
- Referential
Action <referential_action> = { RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT }- Rename
Select Item - Snowflake
RENAMEinformation. - Repetition
Quantifier - Determines the minimum and maximum allowed occurrences of a pattern in a
MATCH_RECOGNIZEoperation. - Reset
Config - RESET config option:
- Role
Option - An option in
ROLEstatement. - Rows
PerMatch - The rows per match option in a
MATCH_RECOGNIZEoperation. - Schema
Name - Schema possible naming variants (1).
- Search
Modifier - Fulltext search modifiers (1).
- Secondary
Roles - Snowflake
SECONDARY ROLESUSE variant See: https://docs.snowflake.com/en/sql-reference/sql/use-secondary-roles - Select
Item - One item of the comma-separated list following
SELECT - Sequence
Options - Can use to describe options in create sequence or table column type identity
- SetConfig
Value - 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.
- Show
Create Object - Show
Statement Filter - Show
Statement Filter Position - Show
Statement InClause - Show
Statement InParent Type - SqlOption
- Sqlite
OnConflict - Sqlite specific syntax
- Statement
- A top-level statement (SELECT, INSERT, CREATE, etc.)
- Struct
Bracket Kind - Type of brackets used for
STRUCTliterals. - Subscript
- The contents inside the
[and]in a subscript expression. - Table
Constraint - A table-level constraint, specified in a
CREATE TABLEor anALTER TABLE ADD <constraint>statement. - Table
Factor - A table name or a parenthesized subquery with an optional alias
- Table
Options Clustered - Table
Version - Timezone
Info - Timestamp and Time data types information about TimeZone formatting.
- TopQuantity
- Transaction
Access Mode - Transaction
Isolation Level - Transaction
Mode - Transaction
Modifier - SQLite specific syntax
- Trigger
Event - Used to describe trigger events
- Trigger
Exec Body Type - Types of trigger body execution body.
- Trigger
Object - This specifies whether the trigger function should be fired once for every row affected by the trigger event, or just once per SQL statement.
- Trigger
Period - Trigger period
- Trigger
Referencing Type - This clause indicates whether the following relation name is for the before-image transition relation or the after-image transition relation
- Trim
Where Field - Truncate
Cascade Option - PostgreSQL cascade option for TRUNCATE table [ CASCADE | RESTRICT ]
- Truncate
Identity Option - PostgreSQL identity option for TRUNCATE table [ RESTART IDENTITY | CONTINUE IDENTITY ]
- Unary
Operator - Unary operators
- Use
- A
USE(Statement::Use) operation - User
Defined Type Representation - SQL user defined type definition
- Value
- Primitive SQL values such as number and string
- Value
Table Mode - BigQuery supports ValueTables which have 2 modes:
SELECT AS STRUCTSELECT AS VALUEhttps://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#value_tables - Window
Frame Bound - Specifies WindowFrame’s
start_boundandend_bound - Window
Frame Units - Window
Type - Wrapped
Collection - Helper to indicate if a collection should be wrapped by a symbol in the display form
Traits§
- Spanned
- Trait for AST nodes that have a source location information.
- Visit
- A type that can be visited by a
Visitor. SeeVisitorfor recursively visiting parsed SQL statements. - Visit
Mut - A type that can be visited by a
VisitorMut. SeeVisitorMutfor recursively visiting parsed SQL statements. - Visitor
- A visitor that can be used to walk an AST tree.
- Visitor
Mut - A visitor that can be used to mutate an AST tree.
Functions§
- display_
comma_ separated - display_
separated - escape_
double_ quote_ string - escape_
quoted_ string - visit_
expressions - Invokes the provided closure on all expressions (e.g.
1 + 2) present inv - 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 inv