classFunctionTable
final class FunctionTable
implements Relation
uses Snapshot
@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.
$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)']$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\InvalidConstructionProperties§
public non-empty-list<TableFunction> $functionspublic list<Name> $columnspublic list<TypedColumn> $definitionspublic bool $rowsFrom = falsepublic bool $ordinality = falsepublic Name|null $alias = nullpublic bool $lateral = falseMethods§
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
$functions | list<TableFunction> | The function calls in written order; one unless ROWS FROM is written |
$rowsFrom | bool | Whether ROWS FROM is written |
$ordinality | bool | Whether WITH ORDINALITY is written |
$alias | Name|null | The correlation name |
$columns | list<Name> | The column names written after the correlation name |
$definitions | list<TypedColumn> | The column definitions written after the correlation name or AS |
$lateral | bool | Whether LATERAL is written |
Calls 6
- static-call Check::listOf() line 75
- class-const TableFunction::class() line 75
- class-const Name::class() line 76
- class-const TypedColumn::class() line 77
- static-call Check::input() line 78
- function-call
countline 78
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFactDerives the calls and the columns of the occurrence.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 2
- method-call FunctionShapes::derive() line 88
- new FunctionShapes line 88
public function name(): ?NameAnswers the name the occurrence is known by without an alias: the name of its first function.
Returns
?NameCalls 2
- method-call FunctionShapes::functionName() line 96
- new FunctionShapes line 96
public function render(Output $out): voidWrites LATERAL, the calls, WITH ORDINALITY and the alias with its columns or column definitions.
Parameters
$out | Output |
Calls 5
- method-call Output::keyword() line 105
- method-call Output::node() line 110
- method-call AliasSpelling::write() line 115
- new AliasSpelling line 115
- method-call Output::symbol() line 120
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
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\Locking::refused() packages/sql-semantics-postgres/src/Rules/Query/Locking.php:140
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::open() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:61
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::visible() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:75
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::visible() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:78