final class GroupingFunction
    implements Scalar, OutputNaming
    uses Snapshot
Public API: explicitly declared with @visibility public.

The grouping operation GROUPING(a, b, …): a bit mask telling which arguments the current grouping set leaves out.

Mirrors PostgreSQL's GroupingFunc node.

Rule: PG-GROUPING-001. Facts: integer, never NULL; an unaliased result column is named grouping. Whether each argument matches a grouping expression is decided by the query that groups. Source: https://www.postgresql.org/docs/17/functions-aggregate.html#FUNCTIONS-GROUPING-TABLE. Status: Implemented.

Reading the arguments of GROUPINGdoctest
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT GROUPING(1, 2)');
    [count($query->field(0)->expression->arguments), $query->field(0)->name->value] // => [2, 'grouping']

Properties§

public non-empty-list<Scalar> $arguments

Methods§

public function __construct(list<Scalar> $arguments)

Parameters

$argumentslist<Scalar>The arguments in order; at least one
Calls 2
public function outputName(): Name

Names an unaliased result column grouping.

Returns

Test cases 1
Calls 1
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the arguments; the result is an integer mask.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 5
public function render(Output $out): void

Writes GROUPING and the arguments.

Parameters

$outOutput
Test cases 1
Calls 1

Test cases 5§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 4
Other tests reaching this symbol 1

Relations§

Instantiated in 1