classGroupingSet
final class GroupingSet
implements Node
uses Snapshot
Public API: explicitly declared with
@visibility public.A grouping set of GROUP BY: the empty set (), ROLLUP, CUBE or GROUPING SETS.
Mirrors PostgreSQL's GroupingSet. ROLLUP and CUBE hold expressions and grouping rows (a row written without ROW groups its fields together); GROUPING SETS holds expressions, grouping rows and nested grouping sets. The selection that holds the set derives its expressions with the rules of GROUP BY. Source: https://www.postgresql.org/docs/17/queries-table-expressions.html#QUERIES-GROUPING-SETS.
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT 1 GROUP BY ROLLUP (1), ()');
[$query->statement->groupBy[0]->kind->value, count($query->statement->groupBy[1]->members)] // => ['ROLLUP', 0]new \SqlSemantics\Platform\PostgreSql\Statement\Query\Grouping\GroupingSet(\SqlSemantics\Platform\PostgreSql\Statement\Query\Grouping\GroupingSetKind::Rollup) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstructionProperties§
public list<Scalar|GroupingRow|GroupingSet> $memberspublic GroupingSetKind $kindMethods§
public function __construct(
public GroupingSetKind $kind,
list<Scalar|GroupingRow|GroupingSet> $members = [],
)Parameters
$kind | GroupingSetKind | The kind of set |
$members | list<Scalar|GroupingRow|GroupingSet> | The members in written order: none for the empty set, expressions and rows for ROLLUP and CUBE, expressions, rows and sets for GROUPING SETS |
Calls 10
- method-call ClosedList::of() line 47
- new ClosedList line 47
- class-const GroupingSetKind::Sets() line 47
- class-const Scalar::class() line 47
- class-const GroupingRow::class() line 47
- class-const GroupingSet::class() line 47
- static-call Check::input() line 49
- method-call Positions::value() line 49
- new Positions line 49
- class-const GroupingSetKind::Empty() line 51
public function render(Output $out): voidWrites the set.
Parameters
$out | Output |
Calls 4
- class-const GroupingSetKind::Empty() line 59
- method-call Output::keyword() line 60
- function-call
explodeline 60 - method-call Output::symbol() line 62
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
GroupingSetTestcalls
Other tests reaching this symbol 1
Relations§
Instantiated in 4
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::groupingSet() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:264
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::groupingSet() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:265
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::groupingSet() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:266
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::groupingSet() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:267