Join¶
- final class lsst.daf.relation.Join(predicate: ~lsst.daf.relation._columns._predicate.Predicate = <factory>, min_columns: frozenset[lsst.daf.relation._columns._tag.ColumnTag] = frozenset({}), max_columns: frozenset[lsst.daf.relation._columns._tag.ColumnTag] | None = None)¶
Bases:
BinaryOperation
A natural join operation.
A natural join combines two relations by matching rows with the same values in their common columns (and satisfying an optional column expression, via a
Predicate
), producing a new relation whose columns are the union of the columns of its operands. This is equivalent to [INNER
]JOIN
in SQL.Attributes Summary
The common columns between relations that will be used as an equality constraint (
Set
[ColumnTag
]).The maximal set of columns that should be used in the equality constraint on
common_columns
(frozenset
[ColumnTag
] orNone
).The minimal set of columns that should be used in the equality constraint on
common_columns
(frozenset
[ColumnTag
]).Methods Summary
applied_columns
(lhs, rhs)Return the columns of the relation that results from applying this operation to the given targets.
applied_common_columns
(lhs, rhs)Compute the actual common columns for a
Join
given its targets.applied_max_rows
(lhs, rhs)Return the maximum number of rows of the relation that results from applying this operation to the given target.
applied_min_rows
(lhs, rhs)Return the minimum number of rows of the relation that results from applying this operation to the given targets.
apply
(lhs, rhs)Create a new relation that represents the action of this operation on a pair of existing relations.
partial
(fix[, is_lhs])Return a
UnaryOperation
that represents this join with one operand already provided and held fixed.Attributes Documentation
- common_columns¶
The common columns between relations that will be used as an equality constraint (
Set
[ColumnTag
]).This attribute is not available on
Join
instances for whichmin_columns
is not the same asmax_columns
. It is always available on anyJoin
instance attached to aBinaryOperationRelation
byapply
.
- max_columns: frozenset[lsst.daf.relation._columns._tag.ColumnTag] | None = None¶
The maximal set of columns that should be used in the equality constraint on
common_columns
(frozenset
[ColumnTag
] orNone
).If the relations this operation is applied to have more columns in common than this set, they will not be included in the equality constraint.
This is guaranteed to be equal to
min_columns
on anyJoin
instance attached to aBinaryOperationRelation
byapply
.
- min_columns: frozenset[lsst.daf.relation._columns._tag.ColumnTag] = frozenset({})¶
The minimal set of columns that should be used in the equality constraint on
common_columns
(frozenset
[ColumnTag
]).If the relations this operation is applied to have common columsn that are not a superset of this set,
ColumnError
will be raised byapply
.This is guaranteed to be equal to
max_columns
on anyJoin
instance attached to aBinaryOperationRelation
byapply
.
Methods Documentation
- applied_columns(lhs: Relation, rhs: Relation) Set[ColumnTag] ¶
Return the columns of the relation that results from applying this operation to the given targets.
- applied_common_columns(lhs: Relation, rhs: Relation) frozenset[ColumnTag] ¶
Compute the actual common columns for a
Join
given its targets.- Parameters:
- Returns:
- common_columns
Set
[ColumnTag
] Columns that are included in all of
lhs.columns
andrhs.columns
andmax_columns
, checked to be a superset ofmin_columns
.
- common_columns
- Raises:
- ColumnError
Raised if the result would not be a superset of
min_columns
.
- applied_max_rows(lhs: Relation, rhs: Relation) int | None ¶
Return the maximum number of rows of the relation that results from applying this operation to the given target.
- applied_min_rows(lhs: Relation, rhs: Relation) int ¶
Return the minimum number of rows of the relation that results from applying this operation to the given targets.
- apply(lhs: Relation, rhs: Relation) Relation ¶
Create a new relation that represents the action of this operation on a pair of existing relations.
- Parameters:
- Returns:
- new_relation
Relation
Relation that includes this operation. This may be
self
if the operation is a no-op, and it may not be aBinaryOperationRelation
holding this operation (or even a similar one) if the operation was inserted earlier in the tree via commutation relations.
- new_relation
- Raises:
- ColumnError
Raised if the operation could not be applied due to problems with the target relations’ columns.
- EngineError
Raised if the operation could not be applied due to problems with the target relations’ engine(s).
- partial(fix: Relation, is_lhs: bool = False) PartialJoin ¶
Return a
UnaryOperation
that represents this join with one operand already provided and held fixed.- Parameters:
- Returns:
- partial_join
PartialJoin
Unary operation representing a join to a fixed relation.
- partial_join
- Raises:
- ColumnError
Raised if the given predicate requires columns not present in
lhs
orrhs
.
Notes
This method and the class it returns are called “partial” in the spirit of
functools.partial
: a callable formed by holding some arguments to another callable fixed.