pub enum TableFactor {
Show 13 variants
Table {
name: ObjectName,
alias: Option<TableAlias>,
args: Option<TableFunctionArgs>,
with_hints: Vec<Expr>,
version: Option<TableVersion>,
with_ordinality: bool,
partitions: Vec<Ident>,
json_path: Option<JsonPath>,
sample: Option<TableSampleKind>,
index_hints: Vec<TableIndexHints>,
},
Derived {
lateral: bool,
subquery: Box<Query>,
alias: Option<TableAlias>,
sample: Option<TableSampleKind>,
},
TableFunction {
expr: Expr,
alias: Option<TableAlias>,
},
Function {
lateral: bool,
name: ObjectName,
args: Vec<FunctionArg>,
alias: Option<TableAlias>,
},
UNNEST {
alias: Option<TableAlias>,
array_exprs: Vec<Expr>,
with_offset: bool,
with_offset_alias: Option<Ident>,
with_ordinality: bool,
},
JsonTable {
json_expr: Expr,
json_path: Value,
columns: Vec<JsonTableColumn>,
alias: Option<TableAlias>,
},
OpenJsonTable {
json_expr: Expr,
json_path: Option<Value>,
columns: Vec<OpenJsonTableColumn>,
alias: Option<TableAlias>,
},
NestedJoin {
table_with_joins: Box<TableWithJoins>,
alias: Option<TableAlias>,
},
Pivot {
table: Box<TableFactor>,
aggregate_functions: Vec<ExprWithAlias>,
value_column: Vec<Expr>,
value_source: PivotValueSource,
default_on_null: Option<Expr>,
alias: Option<TableAlias>,
},
Unpivot {
table: Box<TableFactor>,
value: Expr,
name: Ident,
columns: Vec<ExprWithAlias>,
null_inclusion: Option<NullInclusion>,
alias: Option<TableAlias>,
},
MatchRecognize {
table: Box<TableFactor>,
partition_by: Vec<Expr>,
order_by: Vec<OrderByExpr>,
measures: Vec<Measure>,
rows_per_match: Option<RowsPerMatch>,
after_match_skip: Option<AfterMatchSkip>,
pattern: MatchRecognizePattern,
symbols: Vec<SymbolDefinition>,
alias: Option<TableAlias>,
},
XmlTable {
namespaces: Vec<XmlNamespaceDefinition>,
row_expression: Expr,
passing: XmlPassingClause,
columns: Vec<XmlTableColumn>,
alias: Option<TableAlias>,
},
SemanticView {
name: ObjectName,
dimensions: Vec<Expr>,
metrics: Vec<Expr>,
facts: Vec<Expr>,
where_clause: Option<Expr>,
alias: Option<TableAlias>,
},
}Expand description
A table name or a parenthesized subquery with an optional alias
Variants§
Table
A named table or relation, possibly with arguments, hints, or sampling.
Fields
name: ObjectNameTable or relation name.
alias: Option<TableAlias>Optional alias for the table (e.g. table AS t).
args: Option<TableFunctionArgs>Arguments of a table-valued function, as supported by Postgres
and MSSQL. Note that deprecated MSSQL FROM foo (NOLOCK) syntax
will also be parsed as args.
This field’s value is Some(v), where v is a (possibly empty)
vector of arguments, in the case of a table-valued function call,
whereas it’s None in the case of a regular table name.
version: Option<TableVersion>Optional version qualifier to facilitate table time-travel, as supported by BigQuery and MSSQL.
with_ordinality: boolFor example, SELECT * FROM generate_series(1, 10) WITH ORDINALITY AS t(a, b);
WITH ORDINALITY, supported by Postgres.
partitions: Vec<Ident>Partition selection, supported by MySQL.
json_path: Option<JsonPath>Optional PartiQL JsonPath: https://partiql.org/dql/from.html
sample: Option<TableSampleKind>Optional table sample modifier See: https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#sample-clause
index_hints: Vec<TableIndexHints>Optional index hints(mysql) See: https://dev.mysql.com/doc/refman/8.4/en/index-hints.html
Derived
A derived table (a parenthesized subquery), optionally LATERAL.
Fields
alias: Option<TableAlias>Optional alias for the derived table.
sample: Option<TableSampleKind>Optional table sample modifier
TableFunction
TABLE(<expr>)[ AS <alias> ]
Fields
alias: Option<TableAlias>Optional alias for the table function result.
Function
e.g. LATERAL FLATTEN(<args>)[ AS <alias> ]
Fields
name: ObjectNameName of the table function.
args: Vec<FunctionArg>Arguments passed to the function.
alias: Option<TableAlias>Optional alias for the result of the function.
UNNEST
SELECT * FROM UNNEST ([10,20,30]) as numbers WITH OFFSET;
+---------+--------+
| numbers | offset |
+---------+--------+
| 10 | 0 |
| 20 | 1 |
| 30 | 2 |
+---------+--------+Fields
alias: Option<TableAlias>Optional alias for the UNNEST table (e.g. UNNEST(...) AS t).
JsonTable
The JSON_TABLE table-valued function.
Part of the SQL standard, but implemented only by MySQL, Oracle, and DB2.
https://modern-sql.com/blog/2017-06/whats-new-in-sql-2016#json_table https://dev.mysql.com/doc/refman/8.0/en/json-table-functions.html#function_json-table
SELECT * FROM JSON_TABLE(
'[{"a": 1, "b": 2}, {"a": 3, "b": 4}]',
'$[*]' COLUMNS(
a INT PATH '$.a' DEFAULT '0' ON EMPTY,
b INT PATH '$.b' NULL ON ERROR
)
) AS jt;Fields
json_path: ValueThe path to the array or object to be iterated over. It must evaluate to a json array or object.
columns: Vec<JsonTableColumn>The columns to be extracted from each element of the array or object. Each column must have a name and a type.
alias: Option<TableAlias>The alias for the table.
OpenJsonTable
The MSSQL’s OPENJSON table-valued function.
OPENJSON( jsonExpression [ , path ] ) [ <with_clause> ]
<with_clause> ::= WITH ( { colName type [ column_path ] [ AS JSON ] } [ ,...n ] )Fields
json_path: Option<Value>The path to the array or object to be iterated over. It must evaluate to a json array or object.
columns: Vec<OpenJsonTableColumn>The columns to be extracted from each element of the array or object. Each column must have a name and a type.
alias: Option<TableAlias>The alias for the table.
NestedJoin
Represents a parenthesized table factor. The SQL spec only allows a
join expression ((foo <JOIN> bar [ <JOIN> baz ... ])) to be nested,
possibly several times.
The parser may also accept non-standard nesting of bare tables for some dialects, but the information about such nesting is stripped from AST.
Fields
table_with_joins: Box<TableWithJoins>The nested join expression contained in parentheses.
alias: Option<TableAlias>Optional alias for the nested join.
Pivot
Represents PIVOT operation on a table.
For example FROM monthly_sales PIVOT(sum(amount) FOR MONTH IN ('JAN', 'FEB'))
Fields
table: Box<TableFactor>The input table to pivot.
aggregate_functions: Vec<ExprWithAlias>Aggregate expressions used as pivot values (optionally aliased).
value_source: PivotValueSourceSource of pivot values (e.g. list of literals or columns).
alias: Option<TableAlias>Optional alias for the pivoted table.
Unpivot
An UNPIVOT operation on a table.
Syntax:
table UNPIVOT [ { INCLUDE | EXCLUDE } NULLS ] (value FOR name IN (column1, [ column2, ... ])) [ alias ]See https://docs.snowflake.com/en/sql-reference/constructs/unpivot. See https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-qry-select-unpivot.
Fields
table: Box<TableFactor>The input table to unpivot.
columns: Vec<ExprWithAlias>Columns or expressions to unpivot, optionally aliased.
null_inclusion: Option<NullInclusion>Whether to include or exclude NULLs during unpivot.
alias: Option<TableAlias>Optional alias for the resulting table.
MatchRecognize
A MATCH_RECOGNIZE operation on a table.
See https://docs.snowflake.com/en/sql-reference/constructs/match_recognize.
Fields
table: Box<TableFactor>The input table to apply MATCH_RECOGNIZE on.
order_by: Vec<OrderByExpr>ORDER BY <expr> [, ... ]
rows_per_match: Option<RowsPerMatch>ONE ROW PER MATCH | ALL ROWS PER MATCH [ <option> ]
after_match_skip: Option<AfterMatchSkip>AFTER MATCH SKIP <option>
pattern: MatchRecognizePatternPATTERN ( <pattern> )
symbols: Vec<SymbolDefinition>DEFINE <symbol> AS <expr> [, ... ]
alias: Option<TableAlias>The alias for the table.
XmlTable
The XMLTABLE table-valued function.
Part of the SQL standard, supported by PostgreSQL, Oracle, and DB2.
https://www.postgresql.org/docs/15/functions-xml.html#FUNCTIONS-XML-PROCESSING
SELECT xmltable.*
FROM xmldata,
XMLTABLE('//ROWS/ROW'
PASSING data
COLUMNS id int PATH '@id',
ordinality FOR ORDINALITY,
"COUNTRY_NAME" text,
country_id text PATH 'COUNTRY_ID',
size_sq_km float PATH 'SIZE[@unit = "sq_km"]',
size_other text PATH 'concat(SIZE[@unit!="sq_km"], " ", SIZE[@unit!="sq_km"]/@unit)',
premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified'
);Fields
namespaces: Vec<XmlNamespaceDefinition>Optional XMLNAMESPACES clause (empty if not present)
passing: XmlPassingClauseThe PASSING clause specifying the document expression.
columns: Vec<XmlTableColumn>The columns to be extracted from each generated row.
alias: Option<TableAlias>The alias for the table.
SemanticView
Snowflake’s SEMANTIC_VIEW function for semantic models.
https://docs.snowflake.com/en/sql-reference/constructs/semantic_view
SELECT * FROM SEMANTIC_VIEW(
tpch_analysis
DIMENSIONS customer.customer_market_segment
METRICS orders.order_average_value
);Fields
name: ObjectNameThe name of the semantic model
dimensions: Vec<Expr>List of dimensions or expression referring to dimensions (e.g. DATE_PART(‘year’, col))
alias: Option<TableAlias>The alias for the table
Trait Implementations§
Source§impl Clone for TableFactor
impl Clone for TableFactor
Source§fn clone(&self) -> TableFactor
fn clone(&self) -> TableFactor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TableFactor
impl Debug for TableFactor
Source§impl Display for TableFactor
impl Display for TableFactor
Source§impl Hash for TableFactor
impl Hash for TableFactor
Source§impl Ord for TableFactor
impl Ord for TableFactor
Source§fn cmp(&self, other: &TableFactor) -> Ordering
fn cmp(&self, other: &TableFactor) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for TableFactor
impl PartialEq for TableFactor
Source§impl PartialOrd for TableFactor
impl PartialOrd for TableFactor
Source§impl Spanned for TableFactor
§partial span
Missing spans:
impl Spanned for TableFactor
§partial span
Missing spans:
Source§impl Visit for TableFactor
impl Visit for TableFactor
Source§impl VisitMut for TableFactor
impl VisitMut for TableFactor
Source§fn visit<V: VisitorMut>(&mut self, visitor: &mut V) -> ControlFlow<V::Break>
fn visit<V: VisitorMut>(&mut self, visitor: &mut V) -> ControlFlow<V::Break>
VisitorMut. Read more