MCPcopy
hub / github.com/pathwaycom/pathway / _table_join

Method _table_join

python/pathway/internals/joins.py:996–1121  ·  view source on GitHub ↗
(
        left: Joinable,
        right: Joinable,
        *on: expr.ColumnExpression,
        mode: JoinMode,
        id: expr.ColumnReference | None = None,
        left_instance: expr.ColumnReference | None = None,
        right_instance: expr.ColumnReference | None = None,
        exact_match: bool = False,  # if True do not optionalize output columns even if other than inner join is used
        left_exactly_once: bool = False,
        right_exactly_once: bool = False,
    )

Source from the content-addressed store, hash-verified

994
995 @staticmethod
996 def _table_join(
997 left: Joinable,
998 right: Joinable,
999 *on: expr.ColumnExpression,
1000 mode: JoinMode,
1001 id: expr.ColumnReference | None = None,
1002 left_instance: expr.ColumnReference | None = None,
1003 right_instance: expr.ColumnReference | None = None,
1004 exact_match: bool = False, # if True do not optionalize output columns even if other than inner join is used
1005 left_exactly_once: bool = False,
1006 right_exactly_once: bool = False,
1007 ) -> JoinResult:
1008 if left == right:
1009 raise ValueError(
1010 "Cannot join table with itself. Use <table>.copy() as one of the arguments of the join."
1011 )
1012
1013 left_table, left_substitutions = left._substitutions()
1014 right_table, right_substitutions = right._substitutions()
1015
1016 chained_join_desugaring = SubstitutionDesugaring(
1017 {**left_substitutions, **right_substitutions}
1018 )
1019
1020 if id is not None:
1021 id = chained_join_desugaring.eval_expression(id)
1022 id_column = id._column
1023 else:
1024 id_column = None
1025
1026 common_column_names: StableSet[str] = StableSet()
1027 if left_instance is not None and right_instance is not None:
1028 on = (*on, left_instance == right_instance)
1029 last_column_is_instance = True
1030 else:
1031 assert left_instance is None and right_instance is None
1032 last_column_is_instance = False
1033
1034 on_ = tuple(validate_shape(cond) for cond in on)
1035
1036 for cond in on_:
1037 cond_left = cast(expr.ColumnReference, cond._left)
1038 cond_right = cast(expr.ColumnReference, cond._right)
1039 if cond_left.name == cond_right.name:
1040 common_column_names.add(cond_left.name)
1041
1042 on_ = tuple(chained_join_desugaring.eval_expression(cond) for cond in on_)
1043
1044 for cond in on_:
1045 validate_join_condition(cond, left_table, right_table)
1046
1047 on_left = tuple(
1048 left_table._eval(cond._left, left_table._table_restricted_context)
1049 for cond in on_
1050 )
1051 on_right = tuple(
1052 right_table._eval(cond._right, right_table._table_restricted_context)
1053 for cond in on_

Callers 8

joinMethod · 0.80
join_innerMethod · 0.80
join_leftMethod · 0.80
join_rightMethod · 0.80
join_outerMethod · 0.80
_joinMethod · 0.80
_joinMethod · 0.80
_asof_now_joinMethod · 0.80

Calls 13

addMethod · 0.95
StableSetClass · 0.90
tupleFunction · 0.85
validate_shapeFunction · 0.85
castFunction · 0.85
validate_join_conditionFunction · 0.85
_compute_universeMethod · 0.80
JoinResultClass · 0.70
_substitutionsMethod · 0.45
eval_expressionMethod · 0.45

Tested by

no test coverage detected