classGroupingFunction
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.
$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> $argumentsMethods§
public function __construct(list<Scalar> $arguments)Parameters
$arguments | list<Scalar> | The arguments in order; at least one |
Calls 2
- static-call Check::listOf() line 49
- class-const Scalar::class() line 49
public function outputName(): NameNames an unaliased result column grouping.
Returns
Test cases 1
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the arguments; the result is an integer mask.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 5
- method-call Derivation::scalar() line 66
- new ScalarFact line 69
- new Known line 69
- class-const Builtin::Int4() line 69
- class-const Nullability::NotNull() line 69
public function render(Output $out): voidWrites GROUPING and the arguments.
Parameters
$out | Output |
Test cases 1
Calls 1
- method-call Output::keyword() line 77
Test cases 5§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.