final class Ordering
Restricted visibility: declared "@visibility SqlSemantics\Platform\PostgreSql". Code outside that scope must not name this declaration.

Derives ORDER BY, DISTINCT ON and GROUP BY terms in the environment PostgreSQL resolves each of them in.

Rule: PG-ORDERING-001. An output position denotes the output field at that position (PG-OUTPUT-POSITION-002); any other constant is reported. In ORDER BY and DISTINCT ON, a term that is one unqualified name, possibly in parentheses, and equals the name of output fields denotes that field before any input column; output fields with the name that compute different expressions make it ambiguous. In GROUP BY such a name denotes an input column when the query level has one, and an output field otherwise. Every other term is an expression over the input columns of the selection. After a set operation or VALUES, ORDER BY sees only the output fields; after a set operation a term that is not an output name or position is reported. Terminates: one pass over the terms; grouping sets are walked with a work list. Source: https://www.postgresql.org/docs/17/sql-select.html#SQL-ORDERBY, https://www.postgresql.org/docs/17/sql-select.html#SQL-GROUPBY, https://www.postgresql.org/docs/17/queries-union.html. Status: Implemented.

Methods§

public function group(
    list<Scalar|GroupingRow|GroupingSet> $items,
    list<Field|OpenStar> $projection,
    Derivation $derivation,
    Environment $rows,
): void

Derives the GROUP BY items of a selection, the members of grouping sets included.

Parameters

$itemslist<Scalar|GroupingRow|GroupingSet>
$projectionlist<Field|OpenStar>
$derivationDerivation
$rowsEnvironment
Called from 1
Calls 13
public function outputs(
    list<Scalar> $terms,
    list<Field|OpenStar> $projection,
    Derivation $derivation,
    Environment $outer,
    bool $setOperation,
): void
public function term(
    Scalar $term,
    list<Field|OpenStar> $projection,
    Derivation $derivation,
    Environment $rows,
    OrderingClause $clause,
): void
public function positions(list<Field|OpenStar> $projection, Environment $rows): Environment

Answers the environment an output position is derived in: the known fields, and the relations of an unexpanded star.

Parameters

$projectionlist<Field|OpenStar>
$rowsEnvironment
Test cases 1
Called from 2
Calls 3
public function same(Field $first, Field $second): bool

Tells whether two output fields compute the same expression.

Parameters

$firstField
$secondField

Returns

bool
Test cases 1
Called from 1
Calls 2

Test cases 4§

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

Dedicated tests 4

Relations§

Instantiated in 5
Method calls 6