final class AggregateRule
Restricted visibility: declared "@visibility SqlSemantics\Platform\MySql". Code outside that scope must not name this declaration.

Lowers the aggregate functions: sum_expr with its argument forms, GROUP_CONCAT and JSON_OBJECTAGG.

Rule: MYSQL-CALL-AGGREGATE-001. Scope: sum_expr, in_sum_expr, opt_distinct, opt_gorder_clause, gorder_list, opt_gconcat_separator. Each production names its function, whether DISTINCT is written, the form and position of its argument (an operand with an optional ALL, an expression list, or the star with an optional ALL), and the position of its window (MySQL 8.0 and later). Constructs: Aggregate, GroupConcat, JsonObjectAggregate. Terminates: the ordering list is flattened in a loop; every other child is a strict subtree. Source: https://dev.mysql.com/doc/refman/8.4/en/aggregate-functions.html. Status: Implemented.

Methods§

public function __construct(private Lowering $lowering, private WindowRule $windows)

Parameters

$loweringLoweringThe lowering this rule belongs to
$windowsWindowRuleThe window rules
public function single(Node $operand): array{bool, list<Scalar>}

Lowers the one operand of an aggregate as an argument list.

Parameters

$operandNode

Returns

array{bool, list<Scalar>}
Test cases 1
Called from 1
Calls 1
public function distinct(Node $option): bool

Tells whether DISTINCT is written: a node of opt_distinct.

Parameters

$optionNode

Returns

bool

Throws

ImplementationGap When the production has no rule
Test cases 1
Called from 1
Calls 2
public function ordering(Node $clause): list<OrderItem>

Lowers the ordering of GROUP_CONCAT: a node of opt_gorder_clause.

Parameters

$clauseNode

Returns

list<OrderItem>

Throws

ImplementationGap When a production has no rule
Test cases 1
Called from 1
Calls 4
public function separator(Node $clause): ?Text

Lowers the separator of GROUP_CONCAT: a node of opt_gconcat_separator.

Parameters

$clauseNode

Returns

Throws

ImplementationGap When the production has no rule
Test cases 1
Called from 1
Calls 2

Private surface 5§

Implementation details, listed for orientation only.

private const AGGREGATES = ['sum_expr: AVG_SYM ( in_sum_expr )' => [\SqlSemantics\Platform\MySql\Statement…
private const CONCATENATIONS = ['sum_expr: GROUP_CONCAT_SYM ( opt_distinct expr_list opt_gorder_clause opt_gco…
private const OBJECTS = ['sum_expr: JSON_OBJECTAGG ( in_sum_expr , in_sum_expr )' => null, 'sum_expr: J…
private Lowering $lowering
private WindowRule $windows

Test cases 8§

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

Dedicated tests 8

Relations§

Instantiated in 1
Method calls 1