classWindowSpecification
final class WindowSpecification
implements Clause
uses Snapshot
@visibility public.A window specification in parentheses: an existing window to refine, a partition, an ordering and a frame.
Mirrors PostgreSQL's WindowDef node. It is written after OVER and in the WINDOW clause; the holder derives it in the environment of the query level it belongs to; a frame its own ordering cannot support is reported (PG-WINDOW-CHECKS-001). An existing window named partition, range, rows or groups is written quoted: gram.y reads that word as the keyword after the opening parenthesis (opt_existing_window_name, %prec Op). Source: https://www.postgresql.org/docs/17/sql-expressions.html#SYNTAX-WINDOW-FUNCTIONS, https://www.postgresql.org/docs/17/sql-select.html#SQL-WINDOW.
$window = new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\WindowSpecification();
[$window->existing, $window->partition, $window->order, $window->frame] // => [null, [], [], null]Properties§
public list<Scalar> $partitionpublic list<SortItem> $orderpublic Name|null $existing = nullpublic WindowFrame|null $frame = nullMethods§
public function __construct(
public Name|null $existing = null,
list<Scalar> $partition = [],
list<SortItem> $order = [],
public WindowFrame|null $frame = null,
)Parameters
$existing | Name|null | The window of the WINDOW clause this specification refines |
$partition | list<Scalar> | The partitioning expressions |
$order | list<SortItem> | The ordering within a partition |
$frame | WindowFrame|null | The frame |
Calls 3
- static-call Check::listOf() line 58
- class-const Scalar::class() line 58
- class-const SortItem::class() line 59
public function deriveClause(Derivation $derivation, Environment $environment): voidDerives the partitioning expressions, the ordering and the frame offsets.
Parameters
$derivation | Derivation | |
$environment | Environment |
Test cases 2
Called from 1
Calls 3
- method-call Derivation::scalar() line 68
- method-call WindowChecks::specification() line 74
- new WindowChecks line 74
public function render(Output $out): voidWrites the specification in parentheses.
Parameters
$out | Output |
Test cases 2
Calls 7
- method-call Output::symbol() line 82
- method-call Output::name() line 84
- function-call
in_arrayline 84 - class-const NameUse::Identifier() line 84
- class-const NameUse::Column() line 84
- method-call Output::keyword() line 87
- method-call Output::node() line 92
Test cases 12§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 4
WindowSpecificationTest::testDeriveClauseDerivesPartitionOrderAndFramecallsWindowSpecificationTest::testDeriveClauseReportsAFrameTheOrderingCannotSupportcallsWindowSpecificationTest::testRenderQuotesAnExistingWindowNamedLikeAFrameKeywordcallsWindowSpecificationTest::testRenderWritesTheSpecificationInParenthesescalls
Other tests reaching this symbol 8
CallChecksTest::testMisuseAcceptsAWindowFunctionWithOvercallsWindowChecksTest::testSpecificationLeavesARefinedWindowToTheWindowClausecallsWindowChecksTest::testSpecificationReportsARangeOffsetWithoutASingleOrderingcallsWindowChecksTest::testSpecificationReportsGroupsWithoutOrderingcallsFunctionCallTest::testDeriveScalarDerivesTheClausescallsFunctionCallTest::testRenderWritesDistinctVariadicAndAnInnerOrderingcallsJsonArrayAggregateTest::testRenderWritesTheOrderingAndTheWindowcallsJsonObjectAggregateTest::testDeriveScalarDerivesTheFilterAndTheWindowcalls
Relations§
Instantiated in 1
Method calls 1
Type checks 3
- instanceof SqlSemantics\Platform\PostgreSql\Statement\Invocation\FunctionCall::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/FunctionCall.php:123
- instanceof SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Constructor\JsonArrayAggregate::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Json/Constructor/JsonArrayAggregate.php:88
- instanceof SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Constructor\JsonObjectAggregate::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Json/Constructor/JsonObjectAggregate.php:82
Type declarations 10
- type SqlSemantics\Platform\PostgreSql\Lowering\Invocation\Invocations packages/sql-semantics-postgres/src/Lowering/Invocation/Invocations.php:91
- type SqlSemantics\Platform\PostgreSql\Lowering\Invocation\Invocations packages/sql-semantics-postgres/src/Lowering/Invocation/Invocations.php:101
- type SqlSemantics\Platform\PostgreSql\Lowering\Invocation\JsonRule packages/sql-semantics-postgres/src/Lowering/Invocation/JsonRule.php:133
- type SqlSemantics\Platform\PostgreSql\Lowering\Invocation\WindowRule packages/sql-semantics-postgres/src/Lowering/Invocation/WindowRule.php:81
- type SqlSemantics\Platform\PostgreSql\Lowering\Invocation\WindowRule packages/sql-semantics-postgres/src/Lowering/Invocation/WindowRule.php:99
- type SqlSemantics\Platform\PostgreSql\Rules\Invocation\WindowChecks packages/sql-semantics-postgres/src/Rules/Invocation/WindowChecks.php:31
- type SqlSemantics\Platform\PostgreSql\Statement\Invocation\FunctionCall packages/sql-semantics-postgres/src/Statement/Invocation/FunctionCall.php:91
- type SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Constructor\JsonArrayAggregate packages/sql-semantics-postgres/src/Statement/Invocation/Json/Constructor/JsonArrayAggregate.php:62
- type SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Constructor\JsonObjectAggregate packages/sql-semantics-postgres/src/Statement/Invocation/Json/Constructor/JsonObjectAggregate.php:59
- type SqlSemantics\Platform\PostgreSql\Statement\Query\Clause\WindowDefinition packages/sql-semantics-postgres/src/Statement/Query/Clause/WindowDefinition.php:36