Expand description
SQL Abstract Syntax Tree (AST) types
Modules§
Structs§
- Represents an Array Expression, either
ARRAY[..]
, or[..]
- An
ARRAY_AGG
invocationARRAY_AGG( [ DISTINCT ] <expr> [ORDER BY <expr>] [LIMIT <n>] )
OrARRAY_AGG( [ DISTINCT ] <expr> ) [ WITHIN GROUP ( ORDER BY <expr> ) ]
ORDER BY position is defined differently for BigQuery, Postgres and Snowflake. - SQL assignment
foo = expr
as used in SQLUpdate - SQL column definition
- An optionally-named
ColumnOption
:[ CONSTRAINT <name> ] <column-option>
. <constraint_characteristics> = [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] [ ENFORCED | NOT ENFORCED ]
- Postgres specific feature.
- 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. - A dictionary field within a dictionary.
- Function describe in DROP FUNCTION.
- Bigquery
EXCEPT
information, with at least one column. - A function call
- An identifier, decomposed into its value or character data and the quote style.
- Single aliased identifier
- 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 single column definition in MySQL’s
JSON_TABLE
table valued function. - A hive LATERAL VIEW with potential column aliases
- A
LISTAGG
invocationLISTAGG( [ DISTINCT ] <expr>[, <separator> ] [ON OVERFLOW <on_overflow>] ) ) [ WITHIN GROUP (ORDER BY <within_group1>[, ...] ) ]
NAME = <EXPR>
arguments for DuckDB macros- Expression used to access a value in a nested structure.
- 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 BY
expression - PARTITION statement used in ALTER TABLE et al. such as in Hive SQL
- The most complete variant of a
SELECT
query expression, optionally includingWITH
,UNION
/ other set operations, andORDER BY
. - Syntax
- Bigquery
REPLACE
information. - 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.
- SQL user defined type attribute definition
- Column definition specified in a
CREATE VIEW
statement. - Additional options for wildcards, e.g. Snowflake
EXCLUDE
/RENAME
and BigqueryEXCEPT
. - Specifies the data processed by a window function, e.g.
RANGE UNBOUNDED PRECEDING
orROWS 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.).
- 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.
- Binary operators
- Options for
CAST
/TRY_CAST
BigQuery: https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#formatting_syntax - Possible units for characters, initially based on 2016 ANSI standard.
- Information about character length, including length and possibly unit.
ColumnOption
s are modifiers that follow a column definition in aCREATE TABLE
statement.- Optional context modifier for statements that can be or
LOCAL
, orSESSION
. - A
CSV
option inCOPY
statement before PostgreSQL version 9.0. - An option in
COPY
statement before PostgreSQL version 9.0. - An option in
COPY
statement. - Sql options of a
CREATE TABLE
statement. - SQL data types
- Represents an expression assignment within a variable
DECLARE
statement. - Represents the type of a
DECLARE
statement. - Function describe in DROP FUNCTION.
- Snowflake
EXCLUDE
information. - An SQL expression of any type.
- 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)
- A
FROM
clause within aDELETE
statement. - Operator used to separate function arguments
- 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.
- If it is safe for PostgreSQL to call the function from multiple threads at once
GeneratedAs
s are modifiers that follow a column option in agenerated
. ‘ExpStored’ is used for a column generated from an expression and stored.GeneratedExpressionMode
s 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.
- MySQLs index option.
- Indexing method used by that index.
- JsonOperator
- Stores the error handling clause of a
JSON_TABLE
table 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 OVERFLOW
clause of a LISTAGG invocation - Represents the syntax/style used in a map access.
MERGE
Statement- Can use to describe options in create sequence or table column type identity [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ]
- MySQL
ALTER TABLE
only [FIRST | AFTER column_name] - Mysql specific syntax
- Specifies Ignore / Respect NULL within window functions. For example
FIRST_VALUE(column2) IGNORE NULLS OVER (PARTITION BY column1)
- Stores the keyword after
OFFSET <number>
- Privileges granted in a GRANT statement or revoked in a REVOKE statement.
<referential_action> = { RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT }
- Snowflake
RENAME
information. - RESET config option:
- An option in
ROLE
statement. - 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.)
- A table-level constraint, specified in a
CREATE TABLE
or 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
- Unary operators
- SQL user defined type definition
- Primitive SQL values such as number and string
- BigQuery supports ValueTables which have 2 modes:
SELECT AS STRUCT
SELECT AS VALUE
https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#value_tables
Traits§
- A type that can be visited by a
VisitorMut
. SeeVisitorMut
for 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