classDistinctClause
final class DistinctClause
implements Node
uses Snapshot
Public API: explicitly declared with
@visibility public.DISTINCT or DISTINCT ON: which rows of a selection are kept when they repeat.
Mirrors the distinctClause of PostgreSQL's SelectStmt: an empty list for DISTINCT, the expressions for DISTINCT ON. The DISTINCT ON expressions are interpreted with the rules of ORDER BY; the selection that holds the clause derives them. Source: https://www.postgresql.org/docs/17/sql-select.html#SQL-DISTINCT.
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT DISTINCT ON (1) 1, 2');
count($query->statement->distinct->on) // => 1Properties§
public list<Scalar> $onMethods§
public function __construct(list<Scalar> $on = [])Parameters
$on | list<Scalar> | The DISTINCT ON expressions; empty for plain DISTINCT |
Calls 2
- static-call Check::listOf() line 41
- class-const Scalar::class() line 41
public function render(Output $out): voidWrites DISTINCT and the parenthesized DISTINCT ON expressions.
Parameters
$out | Output |
Calls 1
- method-call Output::keyword() line 49
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
DistinctClauseTestcalls
Relations§
Instantiated in 2
Type declarations 3
- type SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:218
- type SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:245
- type SqlSemantics\Platform\PostgreSql\Statement\Query\Select packages/sql-semantics-postgres/src/Statement/Query/Select.php:88