classFunctionShapes
final class FunctionShapes
Derives the columns of a function call used as a FROM item.
Rule: PG-FUNCTION-TABLE-001. Each call is derived where the FROM items before it are visible. A call with column definitions has those columns, of the defined types; definitions for a call of a known type other than record are reported. A call of a base type has one column, named by the correlation name when it is the only call and has one, else by the function name. A call of type record without definitions has the columns of the routine's declaration, which the context cannot hold: the shape is open on the routine. A call whose type depends on missing declarations leaves the shape open on them. Under ROWS FROM the columns of the calls follow each other and can all be NULL, because shorter results are padded with NULLs. Column definitions written after the alias of ROWS FROM with several functions, or for a function that has its own, are reported (and still derived). WITH ORDINALITY adds the column ordinality of type bigint. The column aliases then rename the columns (PG-COLUMN-ALIAS-001). Source: https://www.postgresql.org/docs/17/queries-table-expressions.html#QUERIES-TABLEFUNCTIONS, https://www.postgresql.org/docs/17/sql-select.html#SQL-FROM. Status: Implemented.
Methods§
public function derive(
FunctionTable $table,
Derivation $derivation,
Environment $environment,
): RelationFactDerives every call and answers the columns of the occurrence.
Parameters
$table | FunctionTable | |
$derivation | Derivation | |
$environment | Environment |
Returns
Called from 1
Calls 24
- function-call
countline 60 - method-call Derivation::report() line 63
- new QueryMisuse line 63
- class-const QueryMisuseRule::RepeatedDefinitions() line 63
- class-const QueryMisuseRule::RowsFromDefinitions() line 63
- method-call Derivation::scalar() line 69
- function-call
array_pushline 72 - method-call FunctionShapes::defined() line 72
- method-call FunctionShapes::functionName() line 75
- new Name line 75
- class-const Builtin::Record() line 76
- new UndeclaredRoutine line 77
- new QualifiedName line 77
- new OutputSlot line 81
- class-const Nullability::Nullable() line 81
- method-call FunctionShapes::padded() line 85
- new Known line 88
- class-const Builtin::Int8() line 88
- class-const Nullability::NotNull() line 88
- new RelationFact line 91
- method-call ColumnAliases::apply() line 91
- new ColumnAliases line 91
- new RowShape line 91
- method-call FunctionShapes::distinct() line 91
public function functionName(TableFunction $function): ?NameAnswers the name a call gives its FROM item and its column: the function name.
Parameters
$function | TableFunction |
Returns
?NameTest cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\FunctionShapes::derive() packages/sql-semantics-postgres/src/Rules/Resolution/FunctionShapes.php:75
- method-call SqlSemantics\Platform\PostgreSql\Statement\Relation\FunctionTable::name() packages/sql-semantics-postgres/src/Statement/Relation/FunctionTable.php:96
public function defined(
list<TypedColumn> $definitions,
ScalarFact $call,
Derivation $derivation,
Environment $environment,
): list<OutputSlot>Derives column definitions and answers their slots.
Parameters
$definitions | list<TypedColumn> | |
$call | ScalarFact | |
$derivation | Derivation | |
$environment | Environment |
Returns
list<OutputSlot>Called from 1
Calls 6
- class-const Builtin::Record() line 110
- method-call Derivation::report() line 111
- new QueryMisuse line 111
- class-const QueryMisuseRule::DefinitionsForBaseType() line 111
- new OutputSlot line 116
- class-const Nullability::Nullable() line 116
public function padded(list<OutputSlot> $slots): list<OutputSlot>Answers the slots made able to be NULL.
Parameters
$slots | list<OutputSlot> |
Returns
list<OutputSlot>Test cases 1
Called from 1
Calls 3
- class-const Nullability::NotNull() line 132
- new OutputSlot line 132
- class-const Nullability::Nullable() line 132
public function distinct(list<MissingInput> $missing): list<MissingInput>Removes repeated missing inputs.
Parameters
$missing | list<MissingInput> |
Returns
list<MissingInput>Test cases 1
Called from 1
Calls 1
- function-call
in_arrayline 148
Test cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Relations§
Instantiated in 2
- new SqlSemantics\Platform\PostgreSql\Statement\Relation\FunctionTable::deriveRelation() packages/sql-semantics-postgres/src/Statement/Relation/FunctionTable.php:88
- new SqlSemantics\Platform\PostgreSql\Statement\Relation\FunctionTable::name() packages/sql-semantics-postgres/src/Statement/Relation/FunctionTable.php:96
Method calls 2
- method-call SqlSemantics\Platform\PostgreSql\Statement\Relation\FunctionTable::deriveRelation() packages/sql-semantics-postgres/src/Statement/Relation/FunctionTable.php:88
- method-call SqlSemantics\Platform\PostgreSql\Statement\Relation\FunctionTable::name() packages/sql-semantics-postgres/src/Statement/Relation/FunctionTable.php:96