classTableSample
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.
$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> $argumentspublic DottedName $methodpublic Scalar|null $seed = nullMethods§
public function __construct(
public DottedName $method,
list<Scalar> $arguments,
public Scalar|null $seed = null,
)Parameters
$method | DottedName | The sampling method |
$arguments | list<Scalar> | The arguments of the method; at least one |
$seed | Scalar|null | The seed written after REPEATABLE |
Calls 2
- static-call Check::listOf() line 44
- class-const Scalar::class() line 44
public function deriveClause(Derivation $derivation, Environment $environment): voidDerives the arguments and the seed.
Parameters
$derivation | Derivation | |
$environment | Environment |
Calls 1
- method-call Derivation::scalar() line 53
public function render(Output $out): voidWrites TABLESAMPLE, the method, its arguments and the seed.
Parameters
$out | Output |
Calls 1
- method-call Output::keyword() line 62
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
TableSampleTestcalls
Other tests reaching this symbol 1
Relations§
Instantiated in 1
Type declarations 3
- type SqlSemantics\Platform\PostgreSql\Lowering\Query\FromRule packages/sql-semantics-postgres/src/Lowering/Query/FromRule.php:133
- type SqlSemantics\Platform\PostgreSql\Lowering\Query\FromRule packages/sql-semantics-postgres/src/Lowering/Query/FromRule.php:374
- type SqlSemantics\Platform\PostgreSql\Statement\Relation\TableInput packages/sql-semantics-postgres/src/Statement/Relation/TableInput.php:49