Module sql_from_models_parser::ast
source · Expand description
SQL Abstract Syntax Tree (AST) types
Structs§
- ALTER TABLE
ASSERT <condition> [AS <message>]- SQL assignment
foo = expras used in SQLUpdate <expr> [ NOT ] BETWEEN <low> AND <high>- Binary operation e.g.
1 + 1orfoo > bar CASE [<operand>] WHEN <condition> THEN <result> ... [ELSE <result>] END- CAST an expression to a different data type e.g.
CAST(foo AS VARCHAR(123)) [ CONSTRAINT <name> ] CHECK (<expr>)expr COLLATE collation- SQL column definition
- An optionally-named
ColumnOption:[ CONSTRAINT <name> ] <column-option>. COMMIT [ TRANSACTION | WORK ] [ AND [ NO ] CHAIN ]- CREATE DATABASE
- CREATE INDEX
- CREATE SCHEMA
- CREATE TABLE
- CREATE VIEW
- SQLite’s
CREATE VIRTUAL TABLE .. USING <module_name> (<module_args>) - 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. DEALLOCATE [ PREPARE ] { name | ALL }- DELETE
- DROP
EXECUTE name [ ( parameter [, ...] ) ]- EXPLAIN
- EXTRACT(DateTimeField FROM
) - A referential integrity constraint (
[ CONSTRAINT <name> ] FOREIGN KEY (<columns>) REFERENCES <foreign_table> (<referred_columns>) { [ON DELETE <referential_action>] [ON UPDATE <referential_action>] | [ON UPDATE <referential_action>] [ON DELETE <referential_action>] }). - A function call
- An identifier, decomposed into its value or character data and the quote style.
[ NOT ] IN (val1, val2, ...)[ NOT ] IN (SELECT ...)- A hive LATERAL VIEW with potential column aliases
- A
LISTAGGinvocationLISTAGG( [ DISTINCT ] <expr>[, <separator> ] [ON OVERFLOW <on_overflow>] ) ) [ WITHIN GROUP (ORDER BY <within_group1>[, ...] ) ] - Msck (Hive)
- A name of a table, view, custom type, etc., possibly multi-part, i.e. db.schema.obj
- An
ORDER BYexpression PREPARE name [ ( data_type [, ...] ) ] AS statement- The most complete variant of a
SELECTquery expression, optionally includingWITH,UNION/ other set operations, andORDER BY. ROLLBACK [ TRANSACTION | WORK ] [ AND [ NO ] CHAIN ]- A restricted variant of
SELECT(without CTEs/ORDER BY), which may appear either as the only body item of anSQLQuery, or as an operand to a set operation likeUNION. SET TRANSACTION ...- SET
- SHOW COLUMNS
- SHOW CREATE TABLE
- SHOW
{ BEGIN [ TRANSACTION | WORK ] | START TRANSACTION } ...- SUBSTRING(
[FROM ] [FOR ]) - TRIM([BOTH | LEADING | TRAILING]
[FROM ])
Or
TRIM() - Truncate (Hive)
- TRY_CAST an expression to a different data type e.g.
TRY_CAST(foo AS VARCHAR(123)) - A constant of form
<data_type> 'value'. This can represent ANSI SQLDATE,TIME, andTIMESTAMPliterals (such asDATE '2020-01-01'), as well as constants of other types (a non-standard PostgreSQL extension). - Unary operation e.g.
NOT foo [ CONSTRAINT <name> ] { PRIMARY KEY | UNIQUE } (<columns>)- UPDATE
- 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 (PARTITION BY .. ORDER BY .. etc.))
Enums§
- An
ALTER TABLE(Statement::AlterTable) operation - Binary operators
ColumnOptions are modifiers that follow a column definition in aCREATE TABLEstatement.- SQL data types
- An SQL expression of any type.
- External table’s available file format
- The
ON OVERFLOWclause of a LISTAGG invocation - Stores the keyword after
OFFSET <number> <referential_action> = { RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT }- One item of the comma-separated list following
SELECT - A node in a tree, representing a “query body” expression, roughly:
SELECT ... [ {UNION|EXCEPT|INTERSECT} SELECT ...] - Sqlite specific syntax
- A top-level statement (SELECT, INSERT, CREATE, etc.)
- 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
- Unary operators
- Primitive SQL values such as number and string