Expand description
SQL Abstract Syntax Tree (AST) types
Modules§
Structs§
- Represents an Array Expression, either
ARRAY[..], or[..] - SQL assignment
foo = expras used in SQLUpdate - SQL column definition
- An optionally-named
ColumnOption:[ CONSTRAINT <name> ] <column-option>. - Joins a table to itself to process hierarchical data in the table.
<constraint_characteristics> = [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] [ ENFORCED | NOT ENFORCED ]- CREATE INDEX statement.
- CREATE TABLE statement.
- 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. - DELETE statement.
- A dictionary field within a dictionary.
- Bigquery
EXCEPTinformation, with at least one column. - An expression optionally followed by an alias.
- A function call
- This represents everything inside the parentheses when calling a function.
- Generic function description for DROP FUNCTION and CREATE TRIGGER.
- The
HAVINGclause in a call toANY_VALUEon BigQuery. - An identifier, decomposed into its value or character data and the quote style.
- Single aliased identifier
- Snowflake
ILIKEinformation. - INSERT statement.
- ClickHouse
INTERPOLATEclause for use inORDER BYclause when usingWITH FILLmodifier. Supported by ClickHouse syntax - 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). - A JSON path.
- A single column definition in MySQL’s
JSON_TABLEtable valued function. - A lambda function.
- A hive LATERAL VIEW with potential column aliases
NAME = <EXPR>arguments for DuckDB macros- Represents a Map expression.
- Expression used to access a value in a nested structure.
- A map field within a map.
- An item in the
MEASURESsubclause of aMATCH_RECOGNIZEoperation. - A when clause within a
MERGEStatement - The expression used to insert rows within a
MERGEstatement. - A name of a table, view, custom type, etc., possibly multi-part, i.e. db.schema.obj
- Function argument in CREATE OR DROP FUNCTION.
- An
ORDER BYexpression - The most complete variant of a
SELECTquery expression, optionally includingWITH,UNION/ other set operations, andORDER BY. - Syntax
- Bigquery
REPLACEinformation. - Snowflake
WITH ROW ACCESS POLICY policy_name ON (identifier, ...) - 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. - A field definition within a struct
- A symbol defined in a
MATCH_RECOGNIZEoperation. - Engine of DB. Some warehouse has parameters of engine, e.g. clickhouse
- Arguments to a table-valued function
- Snowflake
WITH TAG ( tag_name = '<tag_value>', ...) - This keyword immediately precedes the declaration of one or two relation names that provide access to the transition relations of the triggering statement
- This keyword immediately precedes the declaration of one or two relation names that provide access to the transition relations of the triggering statement
- A field definition within a union
- SQL user defined type attribute definition
- Column definition specified in a
CREATE VIEWstatement. - Additional options for wildcards, e.g. Snowflake
EXCLUDE/RENAMEand BigqueryEXCEPT. - Specifies the data processed by a window function, e.g.
RANGE UNBOUNDED PRECEDINGorROWS BETWEEN 5 PRECEDING AND CURRENT ROW. - A window specification (i.e.
OVER ([window_name] PARTITION BY .. ORDER BY .. etc.))
Enums§
- A privilege on a database object (table, sequence, etc.).
- The after match skip option in a
MATCH_RECOGNIZEoperation. - An
ALTER COLUMN(Statement::AlterTable) operation - An
ALTER ROLE(Statement::AlterRole) operation - An
ALTER TABLE(Statement::AlterTable) operation - The mode of an argument in CREATE FUNCTION.
- Represents the data type of the elements in an array (if any) as well as the syntax used to declare the array.
- 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). - Binary operators
- Options for
CAST/TRY_CASTBigQuery: https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#formatting_syntax - The syntax used for in a cast expression.
- The syntax used in a CEIL or FLOOR expression.
- Possible units for characters, initially based on 2016 ANSI standard.
- Information about character length, including length and possibly unit.
ColumnOptions are modifiers that follow a column definition in aCREATE TABLEstatement.- Helper to indicate if a comment includes the
=in the display form - Optional context modifier for statements that can be or
LOCAL, orSESSION. - A
CSVoption inCOPYstatement before PostgreSQL version 9.0. - An option in
COPYstatement before PostgreSQL version 9.0. - An option in
COPYstatement. - Represent the expression body of a
CREATE FUNCTIONstatement as well as where within the statement, the body shows up. - Sql options of a
CREATE TABLEstatement. - SQL data types
- Represents an expression assignment within a variable
DECLAREstatement. - Represents the type of a
DECLAREstatement. - DEDUPLICATE statement used in OPTIMIZE TABLE et al. such as in ClickHouse SQL ClickHouse
- Function describe in DROP FUNCTION.
- Snowflake
EXCLUDEinformation. - An SQL expression of any type.
EXTRACTsyntax variants.- Specific direction for FETCH statement
- External table’s available file format
- FOR XML or FOR JSON clause, specific to MSSQL (formats the output of a query as XML or JSON)
- FORMAT identifier or FORMAT NULL clause, specific to ClickHouse.
- A
FROMclause within aDELETEstatement. - Operator used to separate function arguments
- The arguments passed to a function call.
- These attributes inform the query optimizer about the behavior of the function.
- These attributes describe the behavior of the function when called with a null argument.
- BigQuery Determinism specifier used in a UDF definition.
- If it is safe for PostgreSQL to call the function from multiple threads at once
GeneratedAss are modifiers that follow a column option in agenerated. ‘ExpStored’ is used for a column generated from an expression and stored.GeneratedExpressionModes are modifiers that follow an expression in agenerated. No modifier is typically the same as Virtual.- Objects on which privileges are granted in a GRANT statement.
- ClickHouse supports GROUP BY WITH modifiers(includes ROLLUP|CUBE|TOTALS). e.g. GROUP BY year WITH ROLLUP WITH TOTALS
- MySQLs index option.
- Indexing method used by that index.
- An element of a JSON path.
- Stores the error handling clause of a
JSON_TABLEtable valued function: {NULL | DEFAULT json_string | ERROR} ON {ERROR | EMPTY } - Representation whether a definition can can contains the KEY or INDEX keywords with the same meaning.
- The
ON OVERFLOWclause of a LISTAGG invocation - Represents the syntax/style used in a map access.
- The pattern in a
MATCH_RECOGNIZEoperation. - A symbol in a
MATCH_RECOGNIZEpattern. - Underlying statement of a when clause within a
MERGEStatement - Variant of
WHENclause used within aMERGEStatement. - The type of expression used to insert rows within a
MERGEstatement. - Can use to describe options in create sequence or table column type identity [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ]
- MySQL
ALTER TABLEonly [FIRST | AFTER column_name] - Mysql specific syntax
- An expression used in a named window declaration.
- Specifies Ignore / Respect NULL within window functions. For example
FIRST_VALUE(column2) IGNORE NULLS OVER (PARTITION BY column1) - Stores the keyword after
OFFSET <number> - 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.
- 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
- The source of values in a
PIVOToperation. - Privileges granted in a GRANT statement or revoked in a REVOKE statement.
<referential_action> = { RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT }- Snowflake
RENAMEinformation. - Determines the minimum and maximum allowed occurrences of a pattern in a
MATCH_RECOGNIZEoperation. - RESET config option:
- An option in
ROLEstatement. - The rows per match option in a
MATCH_RECOGNIZEoperation. - Schema possible naming variants (1).
- Fulltext search modifiers (1).
- One item of the comma-separated list following
SELECT - Can use to describe options in create sequence or table column type identity
- SET config value option:
- A node in a tree, representing a “query body” expression, roughly:
SELECT ... [ {UNION|EXCEPT|INTERSECT} SELECT ...] - A quantifier for SetOperator.
- Sqlite specific syntax
- A top-level statement (SELECT, INSERT, CREATE, etc.)
- Type of brackets used for
STRUCTliterals. - The contents inside the
[and]in a subscript expression. - A table-level constraint, specified in a
CREATE TABLEor anALTER TABLE ADD <constraint>statement. - A table name or a parenthesized subquery with an optional alias
- Timestamp and Time data types information about TimeZone formatting.
- SQLite specific syntax
- Used to describe trigger events
- Types of trigger body execution body.
- 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
- This clause indicates whether the following relation name is for the before-image transition relation or the after-image transition relation
- Unary operators
- SQL user defined type definition
- Primitive SQL values such as number and string
- BigQuery supports ValueTables which have 2 modes:
SELECT AS STRUCTSELECT AS VALUEhttps://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#value_tables - Helper to indicate if a collection should be wrapped by a symbol in the display form
Traits§
- A type that can be visited by a
VisitorMut. SeeVisitorMutfor recursively visiting parsed SQL statements. - A visitor that can be used to walk an AST tree.
- A visitor that can be used to mutate an AST tree.
Functions§
- Invokes the provided closure on all expressions (e.g.
1 + 2) present inv - Invokes the provided closure iteratively with a mutable reference to all expressions present in
v. - Invokes the provided closure on all relations (e.g. table names) present in
v - Invokes the provided closure with a mutable reference to all relations (e.g. table names) present in
v. - Invokes the provided closure iteratively with a mutable reference to all statements present in
v(e.g.SELECT,CREATE TABLE, etc). - Invokes the provided closure on all statements (e.g.
SELECT,CREATE TABLE, etc) present inv