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

A function call, or ROWS FROM of several, used as a FROM item.

Mirrors PostgreSQL's RangeFunction. The facts follow PG-FUNCTION-TABLE-001. A function call may refer to the FROM items before it whether or not LATERAL is written; the word is kept as written. Column definitions are written after the alias for one function outside ROWS FROM, and per function inside it. Source: https://www.postgresql.org/docs/17/queries-table-expressions.html#QUERIES-TABLEFUNCTIONS. Status: Implemented.

Reading a function in FROMdoctest
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT * FROM f() WITH ORDINALITY AS x (a integer)');
    [$query->statement->from->ordinality, $query->statement->from->definitions[0]->name->value, $query->toString()] // => [true, 'a', 'SELECT * FROM f() WITH ORDINALITY AS x (a INTEGER)']
Refusing several functions outside ROWS FROMdoctest
$call = new \SqlSemantics\Platform\PostgreSql\Statement\Relation\TableFunction(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral());
    $other = new \SqlSemantics\Platform\PostgreSql\Statement\Relation\TableFunction(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral());
    new \SqlSemantics\Platform\PostgreSql\Statement\Relation\FunctionTable([$call, $other]) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstruction

Properties§

public non-empty-list<TableFunction> $functions
public list<Name> $columns
public list<TypedColumn> $definitions
public bool $rowsFrom = false
public bool $ordinality = false
public Name|null $alias = null
public bool $lateral = false

Methods§

public function __construct(
    list<TableFunction> $functions,
    public bool $rowsFrom = false,
    public bool $ordinality = false,
    public Name|null $alias = null,
    list<Name> $columns = [],
    list<TypedColumn> $definitions = [],
    public bool $lateral = false,
)

Parameters

$functionslist<TableFunction>The function calls in written order; one unless ROWS FROM is written
$rowsFromboolWhether ROWS FROM is written
$ordinalityboolWhether WITH ORDINALITY is written
$aliasName|nullThe correlation name
$columnslist<Name>The column names written after the correlation name
$definitionslist<TypedColumn>The column definitions written after the correlation name or AS
$lateralboolWhether LATERAL is written
Calls 6
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFact

Derives the calls and the columns of the occurrence.

Parameters

$derivationDerivation
$environmentEnvironment
Calls 2
public function name(): ?Name

Answers the name the occurrence is known by without an alias: the name of its first function.

Returns

Calls 2
public function render(Output $out): void

Writes LATERAL, the calls, WITH ORDINALITY and the alias with its columns or column definitions.

Parameters

$outOutput
Calls 5

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 2
Type checks 4
Type declarations 2