final class DerivedTable
    implements Relation
    uses Snapshot
Public API: explicitly declared with @visibility public.

A derived table: [LATERAL] (query) [AS] alias [(columns)].

The query is the one inside the parentheses the syntax requires.

Rule: MYSQL-DERIVED-TABLE-001. The query sees the enclosing queries and, when LATERAL is written, the tables to its left in the same FROM clause (MYSQL-FROM-SCOPE-001). The columns are those of the query, renamed by the column list (MYSQL-DERIVED-SHAPES-001). A derived table without alias is reported. Source: https://dev.mysql.com/doc/refman/8.4/en/derived-tables.html, https://dev.mysql.com/doc/refman/8.4/en/lateral-derived-tables.html. Status: Implemented.

Reading a derived tabledoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT x FROM (SELECT 1) AS d (x)');
    [$query->statement->from->alias?->value, $query->statement->from->columns[0]->value] // => ['d', 'x']

Properties§

public list<Name> $columns
public Query $query
public Name|null $alias = null
public bool $lateral = false
public AliasMark $mark = AliasMark::As

Methods§

public function __construct(
    public Query $query,
    public Name|null $alias = null,
    list<Name> $columns = [],
    public bool $lateral = false,
    public AliasMark $mark = AliasMark::As,
)

Parameters

$queryQueryThe query that produces the rows
$aliasName|nullThe correlation name
$columnslist<Name>The column names
$lateralboolWhether LATERAL is written
$markAliasMarkWhat is written before the alias
Calls 4
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFact

Derives the query and the row shape of the derived table.

Parameters

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

Writes the derived table.

Parameters

$outOutput
Calls 6

Test cases 3§

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 2

Relations§

Instantiated in 3
Type checks 4
Type declarations 1