classFunctionCall
final class FunctionCall
implements Scalar
uses Snapshot
@visibility public.A call of a scalar, aggregate or window function.
Rule: SQLITE-FUNCTION-CALL-001. The arguments, the ordering of aggregate arguments, the filter and the window are derived at the position of the call. The result facts are those of SQLITE-FUNCTION-RESULT-001: a built-in function has its documented result; a wrong number of arguments is reported; any other name depends on the undeclared routine. The star form passes no argument. A clause the kind of function does not take is reported by SQLITE-CALL-CLAUSE-001. Source: https://sqlite.org/lang_expr.html#functions, https://sqlite.org/lang_aggfunc.html, https://sqlite.org/windowfunctions.html. Status: Implemented.
$query = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT count(DISTINCT a) FILTER (WHERE b > 0) FROM t');
$call = $query->statement->columns[0]->expression;
[$call->name->value, $call->quantifier, count($call->arguments), $call->filter !== null, $query->field(0)->nullability] // => ['count', \SqlSemantics\Platform\Sqlite\Statement\Query\SetQuantifier::Distinct, 1, true, \SqlSemantics\Platform\Sqlite\Model\Statement\Type\Nullability::NotNull]new \SqlSemantics\Platform\Sqlite\Statement\Expression\FunctionCall(new \SqlSemantics\Platform\Sqlite\Model\Statement\Identifier\Name('count'), [new \SqlSemantics\Platform\Sqlite\Statement\Expression\Literal\NullLiteral()], true) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionnew \SqlSemantics\Platform\Sqlite\Statement\Expression\FunctionCall(new \SqlSemantics\Platform\Sqlite\Model\Statement\Identifier\Name('count'), [], true, \SqlSemantics\Platform\Sqlite\Statement\Query\SetQuantifier::Distinct) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionProperties§
public list<Scalar> $argumentspublic list<SortTerm> $orderpublic Name $namepublic bool $star = falsepublic SetQuantifier|null $quantifier = nullpublic Scalar|null $filter = nullpublic WindowSpec|Name|null $over = nullMethods§
public function __construct(
public Name $name,
list<Scalar> $arguments = [],
public bool $star = false,
public SetQuantifier|null $quantifier = null,
list<SortTerm> $order = [],
public Scalar|null $filter = null,
public WindowSpec|Name|null $over = null,
)Parameters
$name | Name | The function name |
$arguments | list<Scalar> | The arguments in order |
$star | bool | Whether the argument list is the star |
$quantifier | SetQuantifier|null | The written DISTINCT or ALL |
$order | list<SortTerm> | The ordering written inside the argument list |
$filter | Scalar|null | The FILTER predicate |
$over | WindowSpec|Name|null | The window written after OVER: a specification or a window name |
Calls 4
- static-call Check::listOf() line 79
- class-const Scalar::class() line 79
- class-const SortTerm::class() line 80
- static-call Check::input() line 81
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives every part of the call and the result of the function.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 6
- method-call Derivation::scalar() line 91
- method-call CallChecks::report() line 102
- new CallChecks line 102
- method-call Functions::result() line 103
- new Functions line 103
- method-call Derivation::report() line 105
public function render(Output $out): voidWrites the call.
Parameters
$out | Output |
Calls 6
- method-call Output::name() line 116
- class-const NameUse::Routine() line 116
- method-call Output::symbol() line 118
- method-call Output::keyword() line 121
- method-call Output::list() line 123
- class-const NameUse::Label() line 132
Test cases 32§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 3
Other tests reaching this symbol 29
CallRuleTest::testExpressionKeepsTheArgumentOrderingOfAnAggregatecallsCallRuleTest::testExpressionLowersTheArgumentsTheStarFormAndTheQuantifiercallsCallRuleTest::testFilterLowersThePredicateOfTheFilterClausecallsCallRuleTest::testFilterOverLowersAFilterOnlyAWindowOnlyAndBothcallsCallRuleTest::testNameKeepsTheFunctionNameAsWrittencallsCallRuleTest::testOverLowersAWindowSpecificationOrAWindowNamecallsExpressionRuleTest::testListLowersAnEmptyAndAFilledExpressionListcallsWindowRuleTest::testBoundLowersEveryBoundaryKindWithItsOffsetcallsWindowRuleTest::testExclusionLowersEachExclusionAndNullWithoutItcallsWindowRuleTest::testFrameLowersAStartOnlyFrameAndABetweenFrameOfEveryUnitcallsWindowRuleTest::testWindowLowersEachOfTheSixSpecificationFormscallsSortRuleTest::testTermsTreatsAnIntegerAsAResultColumnPositionOnlyInTheOrderByOfAQuerycallsCanonicalTest::testLayoutSpellsTheRenderedPiecesWithTheirGapscallsAggregationTest::testAggregatesTellsAnAggregateByItsArgumentCountcallsResultNamesTest::testInnerLooksThroughParenthesesCollateAndTheLikelihoodFunctionscallsCallChecksTest::testBrokenAnswersTheRulesInAFixedOrderForEachKindcallsCallChecksTest::testBrokenOfAPlainCallDependsOnTheKindOnlycallsCallChecksTest::testReportRecordsThroughTheDerivationcallsFrameBoundKindTest::testCasesMatchTheBoundariesOfAnAnalyzedFramecallsFrameBoundTest::testReadsTheOffsetOfAnAnalyzedBoundarycallsFrameBoundTest::testRenderWritesANewlyBuiltBoundarycallsFrameExclusionTest::testFromMatchesTheExclusionOfAnAnalyzedFramecallsFrameTest::testReadsBothEndsAndTheExclusioncallsFrameTest::testRenderWritesANewlyBuiltFramecallsFrameUnitTest::testFromMatchesTheUnitOfAnAnalyzedFramecallsWindowDefinitionTest::testRenderWritesANewlyBuiltDefinitioncallsWindowSpecTest::testExpressionsListsPartitionOrderingAndOffsetsInWrittenOrdercallsWindowSpecTest::testReadsEveryPartOfAnAnalyzedWindowcallsWindowSpecTest::testRenderWritesANewlyBuiltSpecificationcalls
Relations§
Instantiated in 6
- new SqlSemantics\Platform\Sqlite\Lowering\Expression\CallRule::expression() packages/sql-semantics-sqlite/src/Lowering/Expression/CallRule.php:47
- new SqlSemantics\Platform\Sqlite\Lowering\Expression\CallRule::expression() packages/sql-semantics-sqlite/src/Lowering/Expression/CallRule.php:48
- new SqlSemantics\Platform\Sqlite\Lowering\Expression\CallRule::expression() packages/sql-semantics-sqlite/src/Lowering/Expression/CallRule.php:49
- new SqlSemantics\Platform\Sqlite\Lowering\Expression\CallRule::expression() packages/sql-semantics-sqlite/src/Lowering/Expression/CallRule.php:50
- new SqlSemantics\Platform\Sqlite\Lowering\Expression\CallRule::expression() packages/sql-semantics-sqlite/src/Lowering/Expression/CallRule.php:51
- new SqlSemantics\Platform\Sqlite\Lowering\Expression\CallRule::expression() packages/sql-semantics-sqlite/src/Lowering/Expression/CallRule.php:52
Constant reads 1
Type checks 3
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Expression\Limits::classify() packages/sql-semantics-sqlite/src/Rules/Definition/Expression/Limits.php:126
- instanceof SqlSemantics\Platform\Sqlite\Rules\Query\Aggregation::aggregates() packages/sql-semantics-sqlite/src/Rules/Query/Aggregation.php:40
- instanceof SqlSemantics\Platform\Sqlite\Rules\Query\ResultNames::inner() packages/sql-semantics-sqlite/src/Rules/Query/ResultNames.php:197