Expand description
SQL Abstract Syntax Tree (AST) types
Modules§
Structs§
- Array
- Represents an Array Expression, either
ARRAY[..]
, or[..]
- Array
Agg - 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. - Assignment
- SQL assignment
foo = expr
as used in SQLUpdate - Column
Def - SQL column definition
- Column
Option Def - An optionally-named
ColumnOption
:[ CONSTRAINT <name> ] <column-option>
. - Constraint
Characteristics <constraint_characteristics> = [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] [ ENFORCED | NOT ENFORCED ]
- Create
Function Body - Postgres specific feature.
- Cte
- A single CTE (used after
WITH
):alias [(col1, col2, ...)] AS ( 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. - DoUpdate
- Dollar
Quoted String - Drop
Function Desc - Function describe in DROP FUNCTION.
- Except
Select Item - Bigquery
EXCEPT
information, with at least one column. - Fetch
- Function
- A function call
- Hive
Format - Ident
- An identifier, decomposed into its value or character data and the quote style.
- Ident
With Alias - 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
- Json
Table Column - A single column definition in MySQL’s
JSON_TABLE
table valued function. - Lateral
View - A hive LATERAL VIEW with potential column aliases
- ListAgg
- A
LISTAGG
invocationLISTAGG( [ DISTINCT ] <expr>[, <separator> ] [ON OVERFLOW <on_overflow>] ) ) [ WITHIN GROUP (ORDER BY <within_group1>[, ...] ) ]
- Lock
Clause - Lock
Table - Macro
Arg NAME = <EXPR>
arguments for DuckDB macros- Named
Window Definition - Object
Name - A name of a table, view, custom type, etc., possibly multi-part, i.e. db.schema.obj
- Offset
- OnConflict
- Operate
Function Arg - Function argument in CREATE OR DROP FUNCTION.
- Order
ByExpr - An
ORDER BY
expression - Partition
- PARTITION statement used in ALTER TABLE et al. such as in Hive SQL
- Procedure
Param - Query
- The most complete variant of a
SELECT
query expression, optionally includingWITH
,UNION
/ other set operations, andORDER BY
. - Replace
Select Element - Syntax
- Replace
Select Item - Bigquery
REPLACE
information. - 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 - SqlOption
- Struct
Field - A field definition within a struct.
- Table
- A
TABLE
command - Table
Alias - Table
With Joins - Top
- User
Defined Type Composite Attribute Def - SQL user defined type attribute definition
- Values
- View
Column Def - Column definition specified in a
CREATE VIEW
statement. - Wildcard
Additional Options - Additional options for wildcards, e.g. Snowflake
EXCLUDE
/RENAME
and BigqueryEXCEPT
. - Window
Frame - Specifies the data processed by a window function, e.g.
RANGE UNBOUNDED PRECEDING
orROWS BETWEEN 5 PRECEDING AND CURRENT ROW
. - Window
Spec - A window specification (i.e.
OVER (PARTITION BY .. ORDER BY .. etc.)
) - With
Enums§
- Action
- A privilege on a database object (table, sequence, etc.).
- AddDrop
Sync - Alter
Column Operation - An
ALTER COLUMN
(Statement::AlterTable
) operation - Alter
Index 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.
- Binary
Operator - Binary operators
- Cast
Format - Options for
CAST
/TRY_CAST
BigQuery: https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#formatting_syntax - 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 ColumnOption
s are modifiers that follow a column definition in aCREATE TABLE
statement.- Comment
Object - Conflict
Target - Context
Modifier - Optional context modifier for statements that can be or
LOCAL
, orSESSION
. - Copy
Legacy CsvOption - A
CSV
option inCOPY
statement before PostgreSQL version 9.0. - Copy
Legacy Option - An option in
COPY
statement before PostgreSQL version 9.0. - Copy
Option - An option in
COPY
statement. - Copy
Source - Copy
Target - Create
Function Using - Create
Table Options - Sql options of a
CREATE TABLE
statement. - Data
Type - SQL data types
- Date
Time Field - Deferrable
Initial - Discard
Object - Distinct
- Drop
Function Option - Function describe in DROP FUNCTION.
- Exact
Number Info - Additional information for
NUMERIC
,DECIMAL
, andDEC
data types following the 2016 standard. - Exclude
Select Item - Snowflake
EXCLUDE
information. - Expr
- An SQL expression of any type.
- 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
- Function
Arg - Function
ArgExpr - Function
Behavior - These attributes inform the query optimizer about the behavior of the function.
- Function
Definition - Generated
As GeneratedAs
s are modifiers that follow a column option in agenerated
. ‘ExpStored’ is used for a column generated from an expression and stored.- Generated
Expression Mode GeneratedExpressionMode
s 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 - Hive
Distribution Style - HiveIO
Format - Hive
RowFormat - Index
Type - Indexing method used by that index.
- Join
Constraint - Join
Operator - Json
Operator - JsonOperator
- Json
Table Column Error Handling - Stores the error handling clause of a
JSON_TABLE
table 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 OVERFLOW
clause of a LISTAGG invocation - Lock
Table Type - Lock
Type - Macro
Definition - Merge
Clause - MinMax
Value - Can use to describe options in create sequence or table column type identity [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ]
- Mysql
Insert Priority - Mysql specific syntax
- NonBlock
- Null
Treatment - Specifies Ignore / Respect NULL within window functions.
For example
FIRST_VALUE(column2) IGNORE NULLS OVER (PARTITION BY column1)
- Object
Type - Offset
Rows - Stores the keyword after
OFFSET <number>
- OnCommit
- OnConflict
Action - OnInsert
- Password
- 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
RENAME
information. - Reset
Config - RESET config option:
- Role
Option - An option in
ROLE
statement. - Schema
Name - Schema possible naming variants (1).
- Search
Modifier - Fulltext search modifiers (1).
- 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 - Sqlite
OnConflict - Sqlite specific syntax
- Statement
- A top-level statement (SELECT, INSERT, CREATE, etc.)
- Table
Constraint - A table-level constraint, specified in a
CREATE TABLE
or anALTER TABLE ADD <constraint>
statement. - Table
Factor - A table name or a parenthesized subquery with an optional alias
- 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
- Trim
Where Field - Unary
Operator - Unary operators
- User
Defined Type Representation - SQL user defined type definition
- Value
- Primitive SQL values such as number and string
- Window
Frame Bound - Specifies WindowFrame’s
start_bound
andend_bound
- Window
Frame Units - Window
Type
Traits§
- Visit
- A type that can be visited by a
Visitor
. SeeVisitor
for recursively visiting parsed SQL statements. - Visit
Mut - A type that can be visited by a
VisitorMut
. SeeVisitorMut
for 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§
- 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