final class TableReference
    implements NamedRelation
    uses Snapshot
Public API: explicitly declared with @visibility public.

One occurrence of a named table, view or common table as query input, with its partition selection, index hints and sampling.

Rule: MYSQL-TABLE-REFERENCE-001. The name resolves by MYSQL-TABLE-SHAPES-001. Partition and index names are not checked: the analysis context holds neither. The sampling percentage is derived by the FROM clause that holds the occurrence. Source: https://dev.mysql.com/doc/refman/8.4/en/join.html, https://dev.mysql.com/doc/refman/8.4/en/partitioning-selection.html. Status: Implemented.

Reading a named inputdoctest
$input = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM shop.t AS x')->singleNamedInput();
    [$input->name()->schema?->value, $input->name()->name->value, $input->alias()?->value] // => ['shop', 't', 'x']
Reading the partitions of a tabledoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t PARTITION (p0, p1)');
    count($query->statement->from->partitions) // => 2

Properties§

public list<Name> $partitions
public list<IndexHint> $indexHints
public Name|null $alias = null
public TableSample|null $sample = null
public AliasMark $mark = AliasMark::As
public OptionalWords $dot = OptionalWords::Omitted

Methods§

public function __construct(
    public QualifiedName $name,
    public Name|null $alias = null,
    list<Name> $partitions = [],
    list<IndexHint> $indexHints = [],
    public TableSample|null $sample = null,
    public AliasMark $mark = AliasMark::As,
    public OptionalWords $dot = OptionalWords::Omitted,
)

Parameters

$nameQualifiedNameThe table name with its optional database
$aliasName|nullThe correlation name
$partitionslist<Name>The selected partitions
$indexHintslist<IndexHint>The index hints
$sampleTableSample|nullThe sampling clause
$markAliasMarkWhat is written before the alias
$dotOptionalWordsWhether the name is written after a leading dot, `.t` (MySQL 5.6 and 5.7)
Calls 6
public function name(): QualifiedName

Answers the table name.

public function alias(): ?Name

Answers the correlation name.

Returns

public function deriveRelation(Derivation $derivation, Environment $environment): RelationFact

Resolves the name, derives the sampling percentage and the row shape of the occurrence.

Parameters

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

Writes the name, the partitions, the correlation name, the index hints and the sampling clause.

Parameters

$outOutput
Calls 11

Test cases 18§

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

Dedicated tests 7
Other tests reaching this symbol 11

Relations§

Instantiated in 1
Type checks 1
Type declarations 1