[][src]Enum postgres_parser::sys::GroupingSetKind

#[repr(u32)]pub enum GroupingSetKind {
    GROUPING_SET_EMPTY,
    GROUPING_SET_SIMPLE,
    GROUPING_SET_ROLLUP,
    GROUPING_SET_CUBE,
    GROUPING_SET_SETS,
}

GroupingSet representation of CUBE, ROLLUP and GROUPING SETS clauses

In a Query with grouping sets, the groupClause contains a flat list of SortGroupClause nodes for each distinct expression used. The actual structure of the GROUP BY clause is given by the groupingSets tree.

In the raw parser output, GroupingSet nodes (of all types except SIMPLE which is not used) are potentially mixed in with the expressions in the groupClause of the SelectStmt. (An expression can't contain a GroupingSet, but a list may mix GroupingSet and expression nodes.) At this stage, the content of each node is a list of expressions, some of which may be RowExprs which represent sublists rather than actual row constructors, and nested GroupingSet nodes where legal in the grammar. The structure directly reflects the query syntax.

In parse analysis, the transformed expressions are used to build the tlist and groupClause list (of SortGroupClause nodes), and the groupingSets tree is eventually reduced to a fixed format:

EMPTY nodes represent (), and obviously have no content

SIMPLE nodes represent a list of one or more expressions to be treated as an atom by the enclosing structure; the content is an integer list of ressortgroupref values (see SortGroupClause)

CUBE and ROLLUP nodes contain a list of one or more SIMPLE nodes.

SETS nodes contain a list of EMPTY, SIMPLE, CUBE or ROLLUP nodes, but after parse analysis they cannot contain more SETS nodes; enough of the syntactic transforms of the spec have been applied that we no longer have arbitrarily deep nesting (though we still preserve the use of cube/rollup).

Note that if the groupingSets tree contains no SIMPLE nodes (only EMPTY nodes at the leaves), then the groupClause will be empty, but this is still an aggregation query (similar to using aggs or HAVING without GROUP BY).

As an example, the following clause:

GROUP BY GROUPING SETS ((a,b), CUBE(c,(d,e)))

looks like this after raw parsing:

SETS( RowExpr(a,b) , CUBE( c, RowExpr(d,e) ) )

and parse analysis converts it to:

SETS( SIMPLE(1,2), CUBE( SIMPLE(3), SIMPLE(4,5) ) )

Variants

GROUPING_SET_EMPTY
GROUPING_SET_SIMPLE
GROUPING_SET_ROLLUP
GROUPING_SET_CUBE
GROUPING_SET_SETS

Trait Implementations

impl Clone for GroupingSetKind[src]

impl Copy for GroupingSetKind[src]

impl Debug for GroupingSetKind[src]

impl<'de> Deserialize<'de> for GroupingSetKind[src]

impl Eq for GroupingSetKind[src]

impl Hash for GroupingSetKind[src]

impl PartialEq<GroupingSetKind> for GroupingSetKind[src]

impl Serialize for GroupingSetKind[src]

impl StructuralEq for GroupingSetKind[src]

impl StructuralPartialEq for GroupingSetKind[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.