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

A call of a function, aggregate or window function written with the function's name.

Mirrors PostgreSQL's FuncCall node: the name as written, the arguments, the aggregate ordering (agg_order, inside the parentheses or after WITHIN GROUP), FILTER, OVER, *, DISTINCT and VARIADIC. ALL before the arguments is the default and builds the same node, so it is not kept.

Rule: PG-FUNCTION-CALL-001. The arguments, the ordering, the filter and the window are derived at the call's position. The result is that of PG-CALL-RESULT-001 (CallTyping): a pg_catalog function the call certainly resolves to has its documented result; every other call depends on the undeclared routine. Diagnostics: a positional argument after a named one, a parameter named twice, and clauses the resolved kind of function does not accept. An unqualified call of cube or rollup is written with the name quoted: in GROUP BY gram.y reads CUBE ( and ROLLUP ( as a grouping set. Termination: recursion on the expression tree only. Source: https://www.postgresql.org/docs/17/sql-expressions.html#SQL-EXPRESSIONS-FUNCTION-CALLS, https://www.postgresql.org/docs/17/sql-expressions.html#SYNTAX-AGGREGATES, https://www.postgresql.org/docs/17/sql-expressions.html#SYNTAX-WINDOW-FUNCTIONS. Status: Implemented.

Reading the parts of an aggregate calldoctest
$call = new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\FunctionCall(
        new \SqlSemantics\Platform\PostgreSql\Statement\Name\DottedName([new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('count')]),
        star: true,
    );
    [$call->name->last()->value, $call->star, $call->arguments, $call->outputName()->value] // => ['count', true, [], 'count']
Rejecting arguments next to the stardoctest
new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\FunctionCall(
        new \SqlSemantics\Platform\PostgreSql\Statement\Name\DottedName([new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('count')]),
        [new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\PositionalArgument(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral())],
        true,
    ) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstruction

Properties§

public list<Argument> $arguments
public list<SortItem> $order
public DottedName $name
public bool $star = false
public bool $distinct = false
public bool $variadic = false
public bool $withinGroup = false
public Scalar|null $filter = null
public WindowSpecification|Name|null $over = null

Methods§

public function __construct(
    public DottedName $name,
    list<Argument> $arguments = [],
    public bool $star = false,
    public bool $distinct = false,
    public bool $variadic = false,
    list<SortItem> $order = [],
    public bool $withinGroup = false,
    public Scalar|null $filter = null,
    public WindowSpecification|Name|null $over = null,
)

Parameters

$nameDottedNameThe function name as written
$argumentslist<Argument>The arguments in order
$starboolWhether the argument list is `*`
$distinctboolWhether DISTINCT is written before the arguments
$variadicboolWhether the last argument is passed with VARIADIC
$orderlist<SortItem>The aggregate ordering
$withinGroupboolWhether the ordering is written after WITHIN GROUP
$filterScalar|nullThe FILTER predicate
$overWindowSpecification|Name|nullThe window after OVER: a specification or the name of a window of the WINDOW clause
Calls 4
public function outputName(): Name

Names an unaliased result column after the function.

Returns

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

Derives the arguments, the ordering, the filter and the window, then the result of the call.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 3

Test cases 21§

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

Dedicated tests 13
Other tests reaching this symbol 8

Relations§

Instantiated in 1
Type checks 1
Type declarations 5