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

Function _asof_join

python/pathway/stdlib/temporal/_asof_join.py:421–474  ·  view source on GitHub ↗
(
    self: pw.Table,
    other: pw.Table,
    t_left: pw.ColumnExpression,
    t_right: pw.ColumnExpression,
    *on: pw.ColumnExpression,
    behavior: CommonBehavior | None,
    how: pw.JoinMode,
    defaults: dict[pw.ColumnReference, Any],
    direction: Direction,
    left_instance: expr.ColumnReference | None,
    right_instance: expr.ColumnReference | None,
)

Source from the content-addressed store, hash-verified

419
420
421def _asof_join(
422 self: pw.Table,
423 other: pw.Table,
424 t_left: pw.ColumnExpression,
425 t_right: pw.ColumnExpression,
426 *on: pw.ColumnExpression,
427 behavior: CommonBehavior | None,
428 how: pw.JoinMode,
429 defaults: dict[pw.ColumnReference, Any],
430 direction: Direction,
431 left_instance: expr.ColumnReference | None,
432 right_instance: expr.ColumnReference | None,
433):
434 check_joint_types(
435 {"t_left": (t_left, TimeEventType), "t_right": (t_right, TimeEventType)}
436 )
437 self_with_time = self.with_columns(_pw_time=t_left)
438 other_with_time = other.with_columns(_pw_time=t_right)
439 self_with_time = apply_temporal_behavior(self_with_time, behavior)
440 other_with_time = apply_temporal_behavior(other_with_time, behavior)
441 side_data = {
442 False: _SideData(
443 side=False,
444 original_table=self,
445 table=self_with_time,
446 conds=[],
447 t=self_with_time._pw_time,
448 ),
449 True: _SideData(
450 side=True,
451 original_table=other,
452 table=other_with_time,
453 conds=[],
454 t=other_with_time._pw_time,
455 ),
456 }
457
458 if left_instance is not None and right_instance is not None:
459 on = (*on, left_instance == right_instance)
460 else:
461 assert left_instance is None and right_instance is None
462
463 for cond in on:
464 cond_left, cond_right, _ = validate_join_condition(cond, self, other)
465 side_data[False].conds.append(self_with_time[cond_left.name])
466 side_data[True].conds.append(other_with_time[cond_right.name])
467
468 return AsofJoinResult(
469 side_data=side_data,
470 mode=how,
471 defaults={c._to_internal(): v for c, v in defaults.items()},
472 direction=direction,
473 _filter_out_results_of_forgetting=behavior is None or behavior.keep_results,
474 )
475
476
477@desugar(substitution={pw.left: "self", pw.right: "other"})

Callers 4

asof_joinFunction · 0.85
asof_join_leftFunction · 0.85
asof_join_rightFunction · 0.85
asof_join_outerFunction · 0.85

Calls 8

apply_temporal_behaviorFunction · 0.90
validate_join_conditionFunction · 0.90
check_joint_typesFunction · 0.85
_SideDataClass · 0.85
AsofJoinResultClass · 0.85
with_columnsMethod · 0.80
itemsMethod · 0.80
_to_internalMethod · 0.45

Tested by

no test coverage detected