pub enum TableFactor<X: Extension = NoExt> {
Show 16 variants
Table {
name: ObjectName,
inheritance: RelationInheritance,
json_path: ThinVec<SemiStructuredPathSegment<X>>,
version: Option<Box<TableVersion<X>>>,
partition: ThinVec<Ident>,
alias: Option<Box<TableAlias>>,
indexed_by: Option<Box<IndexedBy>>,
index_hints: ThinVec<IndexHint>,
sample: Option<TableSample<X>>,
table_hints: ThinVec<TableHint>,
meta: Meta,
},
Derived {
lateral: bool,
subquery: Box<Query<X>>,
alias: Option<Box<TableAlias>>,
spelling: DerivedSpelling,
meta: Meta,
},
Function {
lateral: bool,
function: Box<FunctionCall<X>>,
with_ordinality: bool,
alias: Option<Box<TableAlias>>,
column_defs: ThinVec<TableFunctionColumn<X>>,
meta: Meta,
},
RowsFrom {
lateral: bool,
functions: ThinVec<RowsFromItem<X>>,
with_ordinality: bool,
alias: Option<Box<TableAlias>>,
meta: Meta,
},
Unnest {
lateral: bool,
array_exprs: ThinVec<Expr<X>>,
with_ordinality: bool,
alias: Option<Box<TableAlias>>,
column_defs: ThinVec<TableFunctionColumn<X>>,
with_offset: bool,
with_offset_alias: Option<Ident>,
meta: Meta,
},
NestedJoin {
table: Box<TableWithJoins<X>>,
alias: Option<Box<TableAlias>>,
meta: Meta,
},
SpecialFunction {
keyword: SpecialFunctionKeyword,
precision: Option<u32>,
alias: Option<Box<TableAlias>>,
meta: Meta,
},
Pivot {
pivot: Box<Pivot<X>>,
alias: Option<Box<TableAlias>>,
meta: Meta,
},
Unpivot {
unpivot: Box<Unpivot<X>>,
alias: Option<Box<TableAlias>>,
meta: Meta,
},
MatchRecognize {
match_recognize: Box<MatchRecognize<X>>,
alias: Option<Box<TableAlias>>,
meta: Meta,
},
ShowRef {
show: Box<ShowRef<X>>,
alias: Option<Box<TableAlias>>,
meta: Meta,
},
JsonTable {
json_table: Box<JsonTable<X>>,
alias: Option<Box<TableAlias>>,
meta: Meta,
},
XmlTable {
xml_table: Box<XmlTable<X>>,
alias: Option<Box<TableAlias>>,
meta: Meta,
},
OpenJson {
open_json: Box<OpenJson<X>>,
alias: Option<Box<TableAlias>>,
meta: Meta,
},
TableExpr {
expr: Box<Expr<X>>,
alias: Option<Box<TableAlias>>,
meta: Meta,
},
Other {
ext: X,
meta: Meta,
},
}Expand description
The SQL table factor forms represented by the AST.
Variants§
Table
A named table/relation reference, with optional alias, hints, sampling, and time-travel.
Fields
name: ObjectNameThe table name (one or more dot-separated parts).
inheritance: RelationInheritancePostgreSQL ONLY/* inheritance modifier; see RelationInheritance.
json_path: ThinVec<SemiStructuredPathSegment<X>>A PartiQL / SUPER JSON path navigating into a semi-structured column at the
table-source position (FROM src[0].a), attached directly to the table name.
Redshift’s SUPER navigation and Snowflake’s PartiQL access (sqlparser-rs’s
TableFactor::Table::json_path, gated by its supports_partiql). The path is
entered only by a [ immediately after the name — a bracket index root, then
.key / [index] suffixes — so a dotted FROM src.a.b stays a compound
name, never a path. Empty when absent (the path is always
non-empty when present, so an empty ThinVec is the unambiguous “no path”
sentinel — the same pattern as partition). Reuses the
expression-position SemiStructuredPathSegment
vocabulary. Gated by
TableExpressionSyntax::table_json_path.
version: Option<Box<TableVersion<X>>>A version / time-travel modifier (FOR SYSTEM_TIME AS OF …, VERSION AS OF …),
written between the table name and the alias; None when absent. Boxed to
keep this hot enum within its size budget (ADR-0007). Gated by
TableExpressionSyntax::table_version;
see TableVersion.
partition: ThinVec<Ident>MySQL explicit partition selection PARTITION (p0, p1), written between
the table name and the alias; empty when absent. Restricts the scan to the
named partitions/subpartitions. Gated by
TableExpressionSyntax::partition_selection.
alias: Option<Box<TableAlias>>Alias assigned by this syntax.
indexed_by: Option<Box<IndexedBy>>SQLite INDEXED BY <index> / NOT INDEXED index directive, written after the
table name and its optional alias (FROM t AS e INDEXED BY ix); None when
absent. Boxed to keep this hot enum within its size budget (ADR-0007). A
separate axis from MySQL index_hints: a different
dialect, grammar, and cardinality (see IndexedBy). Gated by
TableExpressionSyntax::indexed_by.
index_hints: ThinVec<IndexHint>MySQL index hints (USE|FORCE|IGNORE INDEX|KEY …), written after the
alias; empty when absent. A list because MySQL admits several comma-joined
hints on one table. Gated by
TableExpressionSyntax::index_hints.
sample: Option<TableSample<X>>Optional sample for this syntax.
table_hints: ThinVec<TableHint>MSSQL / T-SQL WITH (...) table hints (WITH (NOLOCK),
WITH (INDEX(ix), FORCESEEK)), written after the alias and the
tablesample clause; empty when absent. A list because T-SQL admits several
comma-joined hints in one WITH (...). A separate axis from
index_hints: a different dialect (T-SQL vs
MySQL) and a different grammar position. Gated by
TableExpressionSyntax::table_hints.
Derived
A derived table — a parenthesized subquery in FROM, optionally LATERAL.
Fields
alias: Option<Box<TableAlias>>Alias assigned by this syntax.
spelling: DerivedSpellingWhether the source wrote the standard parenthesized ( <query> ) or DuckDB’s
bare FROM VALUES (…) AS t row list (no parentheses); see DerivedSpelling.
A BareValues factor’s subquery body is
always a SetExpr::Values and its alias is always Some (the
parser rejects a bare FROM VALUES without one), the invariant the
Render impl relies on to drop the parentheses.
Function
A set-returning function used as a table (a table function), optionally LATERAL.
Fields
function: Box<FunctionCall<X>>The table-function call; see FunctionCall.
alias: Option<Box<TableAlias>>Alias assigned by this syntax.
column_defs: ThinVec<TableFunctionColumn<X>>PostgreSQL func_alias_clause column definition list, e.g. the
(id int, name text) of func(...) AS x(id int, name text). Empty
unless the function returns an anonymous record typed at the call site.
RowsFrom
A PostgreSQL ROWS FROM(f1(…), f2(…)) multi-function table factor.
Fields
functions: ThinVec<RowsFromItem<X>>functions in source order.
alias: Option<Box<TableAlias>>Alias assigned by this syntax.
Unnest
A first-class UNNEST(<expr>[, <expr>…]) table factor: an array/collection
expression expanded into a relation. Modelled as a dedicated node rather than
the generic Function table function for planner-consumer
parity (the downstream planner keys on a distinct UNNEST) — even though
PostgreSQL itself lowers FROM unnest(…) to the same RangeFunction as any
other set-returning function (its parse tree draws no distinction). Gated by
TableFactorSyntax::unnest;
reached only when UNNEST is immediately followed by (, so a bare UNNEST
stays an ordinary relation name.
Fields
lateral: boolLATERAL UNNEST(…): the array expressions correlate against earlier FROM
items (PostgreSQL CROSS JOIN LATERAL unnest(t.arr)).
array_exprs: ThinVec<Expr<X>>The unnested array expressions. PostgreSQL admits several (unnest(a, b),
the multi-array zip); DuckDB and BigQuery take exactly one. An empty list
models PostgreSQL’s degenerate unnest() accept.
with_ordinality: boolPostgreSQL/DuckDB WITH ORDINALITY: append a 1-based ordinal column. BigQuery
has no WITH ORDINALITY — it spells the same idea WITH OFFSET (0-based).
alias: Option<Box<TableAlias>>The correlation alias and its optional untyped column-name list
(AS u(v, ord)), read before the with_offset
tail so both the PostgreSQL (… WITH ORDINALITY AS u(…)) and BigQuery
(… AS u WITH OFFSET) orderings round-trip.
column_defs: ThinVec<TableFunctionColumn<X>>PostgreSQL’s typed func_alias_clause column-definition list
(unnest(x) AS t(a int)); empty for the common untyped form. Carried so the
rare typed spelling round-trips losslessly rather than over-rejecting.
with_offset: boolBigQuery WITH OFFSET: append a 0-based offset column. Gated by
TableFactorSyntax::unnest_with_offset
— a preset-less flag (no shipped dialect enables it, mirroring
QueryTailSyntax::pipe_syntax), since only
BigQuery/ZetaSQL accepts the tail and there is no BigQuery oracle yet.
with_offset_alias: Option<Ident>The BigQuery WITH OFFSET AS <alias> column alias; None for a bare
WITH OFFSET, and always None when with_offset
is false.
NestedJoin
A parenthesized join nested as a table factor: (t1 JOIN t2 ON …).
Fields
table: Box<TableWithJoins<X>>The parenthesized join tree; see TableWithJoins.
alias: Option<Box<TableAlias>>Alias assigned by this syntax.
SpecialFunction
A bare SQL special value function used as a table reference (PostgreSQL
func_table: func_expr_windowless, e.g. SELECT * FROM current_date):
pg_query lowers this to a RangeFunction wrapping a SQLValueFunction,
distinct from an ordinary call — mirrors Expr::SpecialFunction, the same
grammar production in expression position.
Fields
keyword: SpecialFunctionKeywordWhich special-value function; see SpecialFunctionKeyword.
precision: Option<u32>The (precision) modifier, only valid on the temporal forms (mirrors
Expr::SpecialFunction’s precision).
alias: Option<Box<TableAlias>>Alias assigned by this syntax.
Pivot
DuckDB’s <source> PIVOT (<aggregates> FOR <col> IN (<values>) [GROUP BY …])
table factor. The Pivot core is shared with the leading-keyword
Statement::Pivot (tagged
PivotSpelling::TableFactor); this position owns the
trailing AS p alias the statement form has no place for. Boxed — like the
other payload-bearing variants — to keep this hot enum within its size
budget. Gated by
TableFactorSyntax::pivot.
Fields
alias: Option<Box<TableAlias>>Alias assigned by this syntax.
Unpivot
DuckDB’s <source> UNPIVOT [… NULLS] (<value> FOR <name> IN (<cols>)) table
factor — the Unpivot counterpart of Pivot, sharing its core
with Statement::Unpivot. Gated by
TableFactorSyntax::unpivot.
Fields
alias: Option<Box<TableAlias>>Alias assigned by this syntax.
MatchRecognize
The SQL:2016 <source> MATCH_RECOGNIZE (…) row-pattern-recognition table factor
(Snowflake / Oracle). The MatchRecognize operator core carries the
PARTITION BY / ORDER BY / MEASURES / rows-per-match / after-match-skip /
PATTERN / SUBSET / DEFINE clauses; this position owns the trailing AS mr
alias. Boxed — like the other payload-bearing variants — to keep this hot enum
within its size budget (ADR-0007). Gated by
TableFactorSyntax::match_recognize.
Fields
match_recognize: Box<MatchRecognize<X>>The MATCH_RECOGNIZE operator; see MatchRecognize.
alias: Option<Box<TableAlias>>Alias assigned by this syntax.
ShowRef
DuckDB’s DESCRIBE/SHOW/SUMMARIZE utility standing as a table source —
DuckDB’s SHOW_REF table reference (FROM (DESCRIBE SELECT …),
FROM (DESCRIBE PIVOT …), FROM (SHOW databases); all probed on 1.5.4). Unlike
Pivot/Unpivot, these are relation-producing
constructs, not query bodies — DuckDB parse-rejects them at CTE-body position
(A CTE needs a SELECT) while admitting them here — so they get a table-factor
wrapper around the shared ShowRef core, the shape DuckDB itself uses
(its SHOW_REF node carries the same kind + target). This position owns the
trailing AS t alias. Boxed to keep this hot enum within its size
budget. Gated by
TableFactorSyntax::show_ref.
Fields
alias: Option<Box<TableAlias>>Alias assigned by this syntax.
JsonTable
SQL/JSON JSON_TABLE(…) table factor (SQL:2016) — a JSON document decomposed into a
relation by a COLUMNS specification. Boxed to keep this hot enum within its size
budget. Gated by
TableFactorSyntax::json_table.
Fields
alias: Option<Box<TableAlias>>Alias assigned by this syntax.
XmlTable
SQL/XML XMLTABLE(…) table factor (SQL:2006) — an XML document decomposed into a
relation by an XPath row expression and per-column paths. Boxed to keep this hot enum
within its size budget. Gated by
TableFactorSyntax::xml_table.
Fields
alias: Option<Box<TableAlias>>Alias assigned by this syntax.
OpenJson
SQL Server’s OPENJSON(<json> [, <path>]) [WITH (<col> <type> [<path>] [AS JSON], …)]
table factor — a JSON document parsed into a relation, either with the default
key/value/type schema (no WITH) or an explicit column schema. Boxed to keep this
hot enum within its size budget (ADR-0007). Gated by
TableFactorSyntax::open_json.
Fields
alias: Option<Box<TableAlias>>Alias assigned by this syntax.
TableExpr
TABLE(<expr>) — an arbitrary expression evaluated as a set-returning table
source (sqlparser-rs’s TableFactor::TableFunction). Distinct from a named
table function (Function, FROM f(1)), whose head is a
call, not a parenthesized expression, and from the standalone TABLE t query
form (Select::spelling SelectSpelling::TableCommand),
which is a statement-level <explicit table>, not a FROM-position factor at
all. Only Snowflake and Oracle document this exact shape and neither carries a
differential oracle here, so this is gated
TableFactorSyntax::table_expr_factor,
on for Lenient only. Boxed to keep this hot enum within its size budget.
Fields
alias: Option<Box<TableAlias>>Alias assigned by this syntax.
Other
Dialect extension node supplied by the extension type.
Implementations§
Source§impl<X: Extension> TableFactor<X>
impl<X: Extension> TableFactor<X>
Sourcepub fn alias_slot_mut(&mut self) -> Option<&mut Option<Box<TableAlias>>>
pub fn alias_slot_mut(&mut self) -> Option<&mut Option<Box<TableAlias>>>
A mutable handle to this factor’s correlation-alias slot, or None for the
extension Other variant, which carries no alias.
Every grammar factor holds an Option<Box<TableAlias>>; exposing it uniformly lets
a caller inspect or set the alias without matching all twelve variants — used by the
DuckDB prefix-colon-alias reader (FROM <alias> : <factor>) to attach the alias it
parsed ahead of the factor.
Trait Implementations§
Source§impl<X: Clone + Extension> Clone for TableFactor<X>
impl<X: Clone + Extension> Clone for TableFactor<X>
Source§fn clone(&self) -> TableFactor<X>
fn clone(&self) -> TableFactor<X>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'de, X> Deserialize<'de> for TableFactor<X>where
X: Deserialize<'de> + Extension,
impl<'de, X> Deserialize<'de> for TableFactor<X>where
X: Deserialize<'de> + Extension,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl<X: Eq + Extension> Eq for TableFactor<X>
Source§impl<X: Extension + Render> Render for TableFactor<X>
impl<X: Extension + Render> Render for TableFactor<X>
Source§fn render(&self, ctx: &RenderCtx<'_>, f: &mut Formatter<'_>) -> Result
fn render(&self, ctx: &RenderCtx<'_>, f: &mut Formatter<'_>) -> Result
Source§fn operand_binding_power(&self) -> Option<BindingPower>
fn operand_binding_power(&self) -> Option<BindingPower>
None (the default) for a self-delimiting node — an atom, call, or
constructor — that never needs parentheses. Read moreSource§impl<X> Serialize for TableFactor<X>
impl<X> Serialize for TableFactor<X>
Source§impl<X: Extension> Spanned for TableFactor<X>
impl<X: Extension> Spanned for TableFactor<X>
impl<X: PartialEq + Extension> StructuralPartialEq for TableFactor<X>
Auto Trait Implementations§
impl<X> Freeze for TableFactor<X>where
X: Freeze,
impl<X> RefUnwindSafe for TableFactor<X>where
X: RefUnwindSafe,
impl<X> Send for TableFactor<X>where
X: Send,
impl<X> Sync for TableFactor<X>where
X: Sync,
impl<X> Unpin for TableFactor<X>where
X: Unpin,
impl<X> UnsafeUnpin for TableFactor<X>where
X: UnsafeUnpin,
impl<X> UnwindSafe for TableFactor<X>where
X: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> DynAstExt for T
impl<T> DynAstExt for T
Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&dyn Any for downcasting a node back to its concrete type.Source§fn dyn_clone(&self) -> Box<dyn DynAstExt>
fn dyn_clone(&self) -> Box<dyn DynAstExt>
Clone (whose
Self-returning signature cannot go through a vtable).Source§fn dyn_eq(&self, other: &dyn DynAstExt) -> bool
fn dyn_eq(&self, other: &dyn DynAstExt) -> bool
PartialEq (whose &Self argument cannot go through a vtable). Equal
iff other holds the same concrete type and that type deems the values
equal; differently-typed nodes are never equal.