final class PartitionSpec
    implements Clause
    uses Snapshot
Public API: explicitly declared with @visibility public.

PARTITION BY: the strategy and the key of a partitioned table.

Mirrors PostgreSQL's PartitionSpec. The grammar reads the strategy as a name; the server accepts LIST, RANGE and HASH in any letter case and reports any other word. Source: https://www.postgresql.org/docs/17/sql-createtable.html, https://www.postgresql.org/docs/17/ddl-partitioning.html.

Reading the strategydoctest
$create = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE TABLE t (a int) PARTITION BY HASH (a)');
    $create->statement->partitioning->strategy->value // => 'hash'

Properties§

public non-empty-list<PartitionElement> $elements
public Name $strategy

Methods§

public function __construct(public Name $strategy, list<PartitionElement> $elements)

Parameters

$strategyNameThe strategy word
$elementslist<PartitionElement>The key; at least one element
Calls 2
public function deriveClause(Derivation $derivation, Environment $environment): void

Derives the key against the table and reports an unknown strategy.

Parameters

$derivationDerivation
$environmentEnvironment
Calls 7
public function render(Output $out): void

Writes PARTITION BY, the strategy and the key.

Parameters

$outOutput
Calls 1

Test cases 1§

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

Dedicated tests 1

Relations§

Instantiated in 1
Type declarations 2