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

The TABLESAMPLE clause of a table reference (MySQL 9.x grammars): the sampling method and the percentage.

The percentage is a number, a user variable or a parameter marker. The statement that holds the table derives it; it sees no column. Source: https://dev.mysql.com/doc/refman/9.1/en/select.html.

Reading a sampling clausedoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics('mysql-9.1.0'))->analyze('SELECT a FROM t TABLESAMPLE BERNOULLI (10)');
    [$query->statement->from->sample->method, $query->statement->from->sample->percentage->text] // => [\SqlSemantics\Platform\MySql\Statement\Relation\Hint\SamplingMethod::Bernoulli, '10']
Refusing an expression as the percentagedoctest
new \SqlSemantics\Platform\MySql\Statement\Relation\Hint\TableSample(\SqlSemantics\Platform\MySql\Statement\Relation\Hint\SamplingMethod::System, new \SqlSemantics\Platform\MySql\Statement\Literal\NullLiteral()) // throws \SqlSemantics\Platform\MySql\Model\Diagnostic\InvalidConstruction

Properties§

public SamplingMethod $method
public Scalar $percentage

Methods§

public function __construct(public SamplingMethod $method, public Scalar $percentage)

Parameters

$methodSamplingMethodThe sampling method
$percentageScalarThe percentage of rows to sample
Calls 1
public function render(Output $out): void

Writes the clause.

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