classGroupConcat
final class GroupConcat
implements SetFunction
uses Snapshot
@visibility public.A call of GROUP_CONCAT(): the concatenated non-NULL values of a group, with DISTINCT, an ordering and a separator.
Rule: MYSQL-GROUP-CONCAT-001. The arguments of one row are concatenated, the rows in the written order, separated by the separator (a comma by default). The result is a string in the character set of the arguments, binary when one is binary; it is NULL when a group has no non-NULL row. Its length is cut to group_concat_max_len. The grammar of MySQL 8.0 and later accepts OVER, which the server rejects (ER_NOT_SUPPORTED_YET). Terminates: the parts are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/aggregate-functions.html#function_group-concat. Status: Implemented.
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SELECT GROUP_CONCAT(DISTINCT 'a' SEPARATOR ';')");
[$query->field(0)->type->descriptor->name(), $query->field(0)->nullability] // => ['VARCHAR', \SqlSemantics\Platform\MySql\Model\Statement\Type\Nullability::Nullable]Properties§
public list<Scalar> $argumentspublic list<OrderItem> $orderpublic bool $distinct = falsepublic Text|null $separator = nullpublic Name|WindowSpecification|null $over = nullMethods§
public function __construct(
list<Scalar> $arguments,
public bool $distinct = false,
list<OrderItem> $order = [],
public Text|null $separator = null,
public Name|WindowSpecification|null $over = null,
)Parameters
$arguments | list<Scalar> | The concatenated expressions in order; at least one |
$distinct | bool | Whether DISTINCT is written |
$order | list<OrderItem> | The ordering of the rows |
$separator | Text|null | The separator, when written |
$over | Name|WindowSpecification|null | The window written after OVER |
Calls 3
- static-call Check::listOf() line 73
- class-const Scalar::class() line 73
- class-const OrderItem::class() line 74
public function aggregates(): boolTells whether the call aggregates its query block: it has no window.
Returns
boolTest cases 2
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the parts and the result, and reports a window.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 14
- method-call GroupConcat::aggregates() line 90
- method-call HavingScope::leave() line 90
- new HavingScope line 90
- method-call Arguments::one() line 93
- new Arguments line 93
- method-call Windows::derive() line 98
- new Windows line 98
- method-call Derivation::report() line 100
- new UnsupportedWindowing line 100
- class-const WindowingLimit::GroupConcat() line 100
- new ScalarFact line 103
- method-call ResultTyping::type() line 103
- new ResultTyping line 103
- class-const Nullability::Nullable() line 103
public function render(Output $out): voidWrites the call and its window.
Parameters
$out | Output |
Test cases 1
Calls 5
- method-call Output::keyword() line 111
- method-call Output::list() line 115
- method-call Output::symbol() line 122
- method-call Windows::render() line 123
- new Windows line 123
Test cases 5§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.