classFunctionCall
final class FunctionCall
implements Scalar, OutputNaming
uses Snapshot
@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.
$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']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\InvalidConstructionProperties§
public list<Argument> $argumentspublic list<SortItem> $orderpublic DottedName $namepublic bool $star = falsepublic bool $distinct = falsepublic bool $variadic = falsepublic bool $withinGroup = falsepublic Scalar|null $filter = nullpublic WindowSpecification|Name|null $over = nullMethods§
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
$name | DottedName | The function name as written |
$arguments | list<Argument> | The arguments in order |
$star | bool | Whether the argument list is `*` |
$distinct | bool | Whether DISTINCT is written before the arguments |
$variadic | bool | Whether the last argument is passed with VARIADIC |
$order | list<SortItem> | The aggregate ordering |
$withinGroup | bool | Whether the ordering is written after WITHIN GROUP |
$filter | Scalar|null | The FILTER predicate |
$over | WindowSpecification|Name|null | The window after OVER: a specification or the name of a window of the WINDOW clause |
Calls 4
- static-call Check::listOf() line 93
- class-const Argument::class() line 93
- class-const SortItem::class() line 94
- static-call Check::input() line 95
public function outputName(): NameNames an unaliased result column after the function.
Returns
Test cases 1
Calls 1
- method-call DottedName::last() line 105
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the arguments, the ordering, the filter and the window, then the result of the call.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 3
- method-call Derivation::scalar() line 115
- method-call CallTyping::call() line 127
- new CallTyping line 127
public function render(Output $out): voidWrites the call in the order of the grammar.
Parameters
$out | Output |
Test cases 4
Calls 11
- method-call Spelling::dotted() line 136
- new Spelling line 136
- function-call
countline 136 - function-call
in_arrayline 136 - class-const NameUse::Identifier() line 136
- class-const NameUse::Routine() line 136
- method-call Output::glue() line 137
- method-call Output::symbol() line 139
- method-call Output::keyword() line 142
- method-call Output::node() line 151
- class-const NameUse::Column() line 164
Test cases 21§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 13
FunctionCallTest::testDeriveScalarDependsOnAnUndeclaredRoutinecallsFunctionCallTest::testDeriveScalarDerivesTheClausescallsFunctionCallTest::testDeriveScalarReportsAMisusedClausecallsFunctionCallTest::testDeriveScalarTypesACatalogFunctioncallsFunctionCallTest::testDeriveScalarTypesTheStarAggregatecallsFunctionCallTest::testOutputNameIsTheLastPartOfTheNamecallsFunctionCallTest::testRejectsAnOrderingWithoutArgumentscallsFunctionCallTest::testRejectsArgumentsNextToTheStarcallsFunctionCallTest::testRejectsWithinGroupWithDistinctcallsFunctionCallTest::testRenderQuotesANameThatIsAColumnNameKeywordcallsFunctionCallTest::testRenderQuotesAnUnqualifiedCubeOrRollupcallsFunctionCallTest::testRenderWritesDistinctVariadicAndAnInnerOrderingcallsFunctionCallTest::testRenderWritesEveryPartInOrdercalls
Other tests reaching this symbol 8
CallChecksTest::testMisuseAcceptsAWindowFunctionWithOvercallsCallChecksTest::testMisuseReportsAParameterlessAggregateWithoutStarcallsCallChecksTest::testMisuseReportsEveryClauseAPlainFunctionRejectscallsCallTypingTest::testCallDependsOnTheCurrentDatabaseForACatalogQualifiercallsCallTypingTest::testCallDependsWhenAnotherSchemaIsSearchedFirstcallsCallTypingTest::testCallLeavesNamedArgumentsToTheRoutinecallsCallTypingTest::testCallReportsAnImproperNamecallsCallTypingTest::testCallTypesAnExactCatalogMatchcalls
Relations§
Instantiated in 1
Type checks 1
Type declarations 5
- type SqlSemantics\Platform\PostgreSql\Lowering\Invocation\CallRule packages/sql-semantics-postgres/src/Lowering/Invocation/CallRule.php:79
- type SqlSemantics\Platform\PostgreSql\Lowering\Invocation\CallRule packages/sql-semantics-postgres/src/Lowering/Invocation/CallRule.php:117
- type SqlSemantics\Platform\PostgreSql\Rules\Invocation\CallChecks packages/sql-semantics-postgres/src/Rules/Invocation/CallChecks.php:65
- type SqlSemantics\Platform\PostgreSql\Rules\Invocation\CallTyping packages/sql-semantics-postgres/src/Rules/Invocation/CallTyping.php:51
- type SqlSemantics\Platform\PostgreSql\Statement\Utility\Call packages/sql-semantics-postgres/src/Statement/Utility/Call.php:43