[−][src]Enum postgres_parser::sys::GroupingSetKind
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
Trait Implementations
impl Clone for GroupingSetKind
[src]
fn clone(&self) -> GroupingSetKind
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for GroupingSetKind
[src]
impl Debug for GroupingSetKind
[src]
impl<'de> Deserialize<'de> for GroupingSetKind
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Eq for GroupingSetKind
[src]
impl Hash for GroupingSetKind
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<GroupingSetKind> for GroupingSetKind
[src]
fn eq(&self, other: &GroupingSetKind) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl Serialize for GroupingSetKind
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralEq for GroupingSetKind
[src]
impl StructuralPartialEq for GroupingSetKind
[src]
Auto Trait Implementations
impl RefUnwindSafe for GroupingSetKind
impl Send for GroupingSetKind
impl Sync for GroupingSetKind
impl Unpin for GroupingSetKind
impl UnwindSafe for GroupingSetKind
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,