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

TABLESAMPLE method (arguments) [REPEATABLE (seed)]: a sample of the rows of a table.

Mirrors PostgreSQL's RangeTableSample. The arguments and the seed are evaluated once and see no column of the sampled table. Source: https://www.postgresql.org/docs/17/sql-select.html#SQL-FROM.

Reading a table sampledoctest
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT 1 FROM t TABLESAMPLE bernoulli (10) REPEATABLE (1)');
    [$query->statement->from->sample->method->parts[0]->value, $query->statement->from->sample->seed !== null] // => ['bernoulli', true]

Properties§

public non-empty-list<Scalar> $arguments
public DottedName $method
public Scalar|null $seed = null

Methods§

public function __construct(
    public DottedName $method,
    list<Scalar> $arguments,
    public Scalar|null $seed = null,
)

Parameters

$methodDottedNameThe sampling method
$argumentslist<Scalar>The arguments of the method; at least one
$seedScalar|nullThe seed written after REPEATABLE
Calls 2
public function deriveClause(Derivation $derivation, Environment $environment): void

Derives the arguments and the seed.

Parameters

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

Writes TABLESAMPLE, the method, its arguments and the seed.

Parameters

$outOutput
Calls 1

Test cases 2§

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

Dedicated tests 1
Other tests reaching this symbol 1

Relations§

Instantiated in 1
Type declarations 3