classJoining
final class Joining
Combines the two sides of a join into the columns and relations the join makes visible.
Rule: PG-JOIN-001. The columns of a side are the columns it shows to unqualified names. USING names columns that each side must have exactly once; NATURAL uses every column name both sides have. Each such column is merged into one column, first and in USING (or left) order, followed by the other columns of the left side and then of the right side. The merged column has the common type of the pair (PG-UNIFICATION-001) and is the left column for INNER and LEFT joins, the right column for RIGHT joins and the first non-NULL of both for FULL joins. A LEFT join can extend the right side with NULLs, a RIGHT join the left side, a FULL join both: the columns of an extended side can be NULL in the join and keep their declaration. The join itself is visible to unqualified names only; the relations inside stay visible to qualified names, and a USING alias names the merged columns, for qualified names only. A name a side does not have is reported only when the side is completely known. Source: https://www.postgresql.org/docs/17/queries-table-expressions.html#QUERIES-JOIN. Status: Implemented.
Methods§
public function join(
Join $join,
JoinedInput $left,
JoinedInput $right,
Derivation $derivation,
): JoinedInputJoins two derived sides.
Parameters
$join | Join | |
$left | JoinedInput | |
$right | JoinedInput | |
$derivation | Derivation |
Returns
Called from 1
Calls 18
- new Visibility line 52
- method-call Visibility::star() line 53
- method-call Joining::names() line 58
- method-call Joining::locate() line 59
- class-const QueryMisuseRule::UsingColumnNotInLeft() line 59
- class-const QueryMisuseRule::UsingColumnNotInRight() line 60
- new OutputSlot line 64
- new Dependent line 64
- class-const Nullability::Dependent() line 64
- method-call Joining::merged() line 70
- function-call
in_arrayline 74 - method-call Joining::nullable() line 75
- new RowShape line 83
- new VisibleRelation line 84
- method-call Visibility::qualifiedOnly() line 86
- method-call Joining::extended() line 89
- new JoinedInput line 95
- new RelationFact line 95
public function names(
Join $join,
RowShape $left,
RowShape $right,
Derivation $derivation,
): list<Name>Answers the names of the merged columns: the USING list, or the names both sides of a NATURAL join have.
Parameters
$join | Join | |
$left | RowShape | |
$right | RowShape | |
$derivation | Derivation |
Returns
list<Name>Called from 1
Calls 3
- method-call Derivation::report() line 112
- new QueryMisuse line 112
- class-const QueryMisuseRule::UsingColumnRepeated() line 112
public function locate(
RowShape $side,
Name $name,
Derivation $derivation,
QueryMisuseRule $absent,
): ?intFinds the one column of a side with a name, reporting a name the side lacks or repeats when the side is completely known.
Parameters
$side | RowShape | |
$name | Name | |
$derivation | Derivation | |
$absent | QueryMisuseRule |
Returns
?intCalled from 2
Calls 5
- function-call
countline 153 - method-call Derivation::report() line 154
- new QueryMisuse line 154
- class-const QueryMisuseRule::RepeatedCommonColumn() line 154
- method-call RowShape::complete() line 156
public function merged(
JoinKind $kind,
OutputSlot $left,
OutputSlot $right,
Derivation $derivation,
): OutputSlotAnswers the merged column of a pair.
Parameters
$kind | JoinKind | |
$left | OutputSlot | |
$right | OutputSlot | |
$derivation | Derivation |
Returns
Called from 1
Calls 7
- method-call Unification::resolve() line 168
- new Unification line 168
- method-call Derivation::report() line 170
- class-const JoinKind::Right() line 172
- class-const JoinKind::Full() line 173
- method-call Unification::nullability() line 173
- new OutputSlot line 175
public function nullable(OutputSlot $slot): OutputSlotAnswers a slot that the join can extend with NULL, referring to the slot it extends.
Parameters
$slot | OutputSlot |
Returns
Test cases 1
Called from 4
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\Joining::join() packages/sql-semantics-postgres/src/Rules/Resolution/Joining.php:75
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\Joining::join() packages/sql-semantics-postgres/src/Rules/Resolution/Joining.php:80
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\Joining::extended() packages/sql-semantics-postgres/src/Rules/Resolution/Joining.php:193
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\Joining::extended() packages/sql-semantics-postgres/src/Rules/Resolution/Joining.php:197
Calls 2
- class-const Nullability::Nullable() line 183
- new OutputSlot line 183
public function extended(VisibleRelation $relation): VisibleRelationAnswers a relation whose slots the join can extend with NULL.
Parameters
$relation | VisibleRelation |
Returns
Test cases 1
Called from 2
Calls 4
- method-call Joining::nullable() line 193
- new ImplicitSlot line 197
- new VisibleRelation line 200
- new RowShape line 200
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.