Skip to main content

TableFactor

Enum TableFactor 

Source
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>, with_ordinality: bool, 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: ValueWithSpan, columns: Vec<JsonTableColumn>, alias: Option<TableAlias>, }, OpenJsonTable { json_expr: Expr, json_path: Option<ValueWithSpan>, 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: ObjectName

Table 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.

§with_hints: Vec<Expr>

MSSQL-specific WITH (...) hints such as NOLOCK.

§version: Option<TableVersion>

Optional version qualifier to facilitate table time-travel, as supported by BigQuery and MSSQL.

§with_ordinality: bool

For 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

§

Derived

A derived table (a parenthesized subquery), optionally LATERAL.

Fields

§lateral: bool

Whether the derived table is LATERAL.

§subquery: Box<Query>

The subquery producing the derived table.

§alias: Option<TableAlias>

Optional alias for the derived table.

§sample: Option<TableSampleKind>

Optional table sample modifier

§

TableFunction

TABLE(<expr>)[ AS <alias> ]

Fields

§expr: Expr

Expression representing the table function call.

§alias: Option<TableAlias>

Optional alias for the table function result.

§

Function

e.g. LATERAL FLATTEN(<args>)[ AS <alias> ]

Fields

§lateral: bool

Whether the function is LATERAL.

§name: ObjectName

Name of the table function.

§args: Vec<FunctionArg>

Arguments passed to the function.

§with_ordinality: bool

Whether WITH ORDINALITY was specified to include ordinality.

§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).

§array_exprs: Vec<Expr>

Expressions producing the arrays to be unnested.

§with_offset: bool

Whether WITH OFFSET was specified to include element offsets.

§with_offset_alias: Option<Ident>

Optional alias for the offset column when WITH OFFSET is used.

§with_ordinality: bool

Whether WITH ORDINALITY was specified to include ordinality.

§

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_expr: Expr

The JSON expression to be evaluated. It must evaluate to a json string

§json_path: ValueWithSpan

The 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 ] )

Reference: https://learn.microsoft.com/en-us/sql/t-sql/functions/openjson-transact-sql?view=sql-server-ver16#syntax

Fields

§json_expr: Expr

The JSON expression to be evaluated. It must evaluate to a json string

§json_path: Option<ValueWithSpan>

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'))

BigQuery Snowflake Oracle

Fields

§table: Box<TableFactor>

The input table to pivot.

§aggregate_functions: Vec<ExprWithAlias>

Aggregate expressions used as pivot values (optionally aliased).

§value_column: Vec<Expr>

Columns producing the values to be pivoted.

§value_source: PivotValueSource

Source of pivot values (e.g. list of literals or columns).

§default_on_null: Option<Expr>

Optional expression providing a default when a pivot produces NULL.

§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 ]

Snowflake Databricks BigQuery Oracle

Fields

§table: Box<TableFactor>

The input table to unpivot.

§value: Expr

Expression producing the unpivoted value.

§name: Ident

Identifier used for the generated column name.

§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

Fields

§table: Box<TableFactor>

The input table to apply MATCH_RECOGNIZE on.

§partition_by: Vec<Expr>

PARTITION BY <expr> [, ... ]

§order_by: Vec<OrderByExpr>

ORDER BY <expr> [, ... ]

§measures: Vec<Measure>

MEASURES <expr> [AS] <alias> [, ... ]

§rows_per_match: Option<RowsPerMatch>

ONE ROW PER MATCH | ALL ROWS PER MATCH [ <option> ]

§after_match_skip: Option<AfterMatchSkip>

AFTER MATCH SKIP <option>

§pattern: MatchRecognizePattern

PATTERN ( <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)

§row_expression: Expr

The row-generating XPath expression.

§passing: XmlPassingClause

The 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: ObjectName

The name of the semantic model

§dimensions: Vec<Expr>

List of dimensions or expression referring to dimensions (e.g. DATE_PART(‘year’, col))

§metrics: Vec<Expr>

List of metrics (references to objects like orders.value, value, orders.*)

§facts: Vec<Expr>

List of facts or expressions referring to facts or dimensions.

§where_clause: Option<Expr>

WHERE clause for filtering

§alias: Option<TableAlias>

The alias for the table

Trait Implementations§

Source§

impl Clone for TableFactor

Source§

fn clone(&self) -> TableFactor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TableFactor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for TableFactor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for TableFactor

Source§

impl Hash for TableFactor

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for TableFactor

Source§

fn cmp(&self, other: &TableFactor) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for TableFactor

Source§

fn eq(&self, other: &TableFactor) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for TableFactor

Source§

fn partial_cmp(&self, other: &TableFactor) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Spanned for TableFactor

§partial span

Missing spans:

Source§

fn span(&self) -> Span

Return the Span (the minimum and maximum Location) for this AST node, by recursively combining the spans of its children.
Source§

impl StructuralPartialEq for TableFactor

Source§

impl Visit for TableFactor

Source§

fn visit<V>(&self, visitor: &mut V) -> ControlFlow<<V as Visitor>::Break>
where V: Visitor,

Visit this node with the provided Visitor. Read more
Source§

impl VisitMut for TableFactor

Source§

fn visit<V>(&mut self, visitor: &mut V) -> ControlFlow<<V as VisitorMut>::Break>
where V: VisitorMut,

Mutably visit this node with the provided VisitorMut. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<Source> AccessAs for Source

Source§

fn ref_as<T>(&self) -> <Source as IGuardRef<T>>::Guard<'_>
where Source: IGuardRef<T>, T: ?Sized,

Provides immutable access to a type as if it were its ABI-unstable equivalent.
Source§

fn mut_as<T>(&mut self) -> <Source as IGuardMut<T>>::GuardMut<'_>
where Source: IGuardMut<T>, T: ?Sized,

Provides mutable access to a type as if it were its ABI-unstable equivalent.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DynEq for T
where T: Eq + Any,

Source§

fn dyn_eq(&self, other: &(dyn Any + 'static)) -> bool

Source§

impl<T> DynHash for T
where T: Hash + Any,

Source§

fn dyn_hash(&self, state: &mut dyn Hasher)

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, As> IGuardMut<As> for T
where T: Into<As>, As: Into<T>,

Source§

type GuardMut<'a> = MutAs<'a, T, As> where T: 'a

The type of the guard which will clean up the temporary after applying its changes to the original.
Source§

fn guard_mut_inner(&mut self) -> <T as IGuardMut<As>>::GuardMut<'_>

Construct the temporary and guard it through a mutable reference.
Source§

impl<T, As> IGuardRef<As> for T
where T: Into<As>, As: Into<T>,

Source§

type Guard<'a> = RefAs<'a, T, As> where T: 'a

The type of the guard which will clean up the temporary.
Source§

fn guard_ref_inner(&self) -> <T as IGuardRef<As>>::Guard<'_>

Construct the temporary and guard it through an immutable reference.
Source§

impl<T> Includes<End> for T

Source§

type Output = End

The result
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Ungil for T
where T: Send,

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more