final class Aggregate
    implements SetFunction
    uses Snapshot
Public API: explicitly declared with @visibility public.

A call of an aggregate function with one argument, COUNT(*), or COUNT(DISTINCT ...) with several arguments.

Rule: MYSQL-AGGREGATE-001. The server builds the Item_sum classes. DISTINCT counts each distinct value once; ALL, written before the argument, is the default. With OVER the call is a window function (MySQL 8.0 and later). The result follows MYSQL-AGGREGATE-RESULT-001. Terminates: the arguments and the window are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/aggregate-functions.html. Status: Implemented.

Typing COUNT(*)doctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT COUNT(*)');
    [$query->field(0)->type->descriptor->name(), $query->field(0)->nullability] // => ['BIGINT', \SqlSemantics\Platform\MySql\Model\Statement\Type\Nullability::NotNull]
Refusing several arguments without DISTINCTdoctest
new \SqlSemantics\Platform\MySql\Statement\Call\Aggregate\Aggregate(\SqlSemantics\Platform\MySql\Statement\Call\Aggregate\AggregateFunction::Sum, [new \SqlSemantics\Platform\MySql\Statement\Literal\NullLiteral(), new \SqlSemantics\Platform\MySql\Statement\Literal\NullLiteral()]) // throws \SqlSemantics\Platform\MySql\Model\Diagnostic\InvalidConstruction

Properties§

public list<Scalar> $arguments
public AggregateFunction $function
public bool $distinct = false
public bool $all = false
public Name|WindowSpecification|null $over = null

Methods§

public function __construct(
    public AggregateFunction $function,
    list<Scalar> $arguments,
    public bool $distinct = false,
    public bool $all = false,
    public Name|WindowSpecification|null $over = null,
)

Parameters

$functionAggregateFunctionThe function
$argumentslist<Scalar>The arguments in order; none for COUNT(*)
$distinctboolWhether DISTINCT is written
$allboolWhether ALL is written before the argument or the star
$overName|WindowSpecification|nullThe window written after OVER
Calls 6
public function aggregates(): bool
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the arguments, the window and the result.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the call and its window.

Parameters

$outOutput
Test cases 1
Calls 6

Test cases 10§

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 6

Relations§

Instantiated in 1
Type checks 1
Type declarations 1