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

A call of a function that is only a window function: ranking, distribution, and the value functions LEAD, LAG, FIRST_VALUE, LAST_VALUE and NTH_VALUE.

Rule: MYSQL-WINDOW-FUNCTION-001. The window is required. The count of NTILE and the offset of LEAD and LAG are an integer, a parameter marker, a user variable or a routine variable (stable_integer); the row number of NTH_VALUE is a primary expression. The result follows MYSQL-WINDOW-RESULT-001. Terminates: the arguments and the window are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/window-function-descriptions.html. Status: Implemented.

Typing a ranking functiondoctest
(new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT RANK() OVER w') // throws \SqlSemantics\Platform\MySql\Model\Diagnostic\SemanticException: Window name is not defined
Refusing an offset that is not a stable integerdoctest
new \SqlSemantics\Platform\MySql\Statement\Call\Window\WindowFunction(\SqlSemantics\Platform\MySql\Statement\Call\Window\WindowFunctionKind::Tile, [new \SqlSemantics\Platform\MySql\Statement\Literal\NullLiteral()], new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\Name('w')) // throws \SqlSemantics\Platform\MySql\Model\Diagnostic\InvalidConstruction

Properties§

public list<Scalar> $arguments
public NullTreatment|null $nulls = null
public CountingEdge|null $edge = null

Methods§

public function __construct(
    public WindowFunctionKind $kind,
    list<Scalar> $arguments,
    public Name|WindowSpecification $over,
    public NullTreatment|null $nulls = null,
    public CountingEdge|null $edge = null,
)

Parameters

$kindWindowFunctionKindThe function
$argumentslist<Scalar>The arguments in order
$overName|WindowSpecificationThe window written after OVER
$nullsNullTreatment|nullThe written RESPECT NULLS or IGNORE NULLS
$edgeCountingEdge|nullThe written FROM FIRST or FROM LAST of NTH_VALUE
Calls 11
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the arguments, the window and the result.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 6
public function render(Output $out): void

Writes the call, its options and its window.

Parameters

$outOutput
Test cases 1
Calls 4

Test cases 5§

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

Dedicated tests 2
Other tests reaching this symbol 3

Relations§

Instantiated in 1
Type checks 1
Type declarations 2