(
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,
)
| 419 | |
| 420 | |
| 421 | def _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"}) |
no test coverage detected