Performs an interval join of self with other using a time difference and join expressions. If `self_time + lower_bound <= other_time <= self_time + upper_bound` and conditions in `on` are satisfied, the rows are joined. Args: other: the right side of a join. self_ti
(
self: pw.Table,
other: pw.Table,
self_time: pw.ColumnExpression,
other_time: pw.ColumnExpression,
interval: Interval[int] | Interval[float] | Interval[datetime.timedelta],
*on: pw.ColumnExpression,
behavior: CommonBehavior | None = None,
how: pw.JoinMode = pw.JoinMode.INNER,
left_instance: pw.ColumnReference | None = None,
right_instance: pw.ColumnReference | None = None,
)
| 575 | @check_arg_types |
| 576 | @trace_user_frame |
| 577 | def interval_join( |
| 578 | self: pw.Table, |
| 579 | other: pw.Table, |
| 580 | self_time: pw.ColumnExpression, |
| 581 | other_time: pw.ColumnExpression, |
| 582 | interval: Interval[int] | Interval[float] | Interval[datetime.timedelta], |
| 583 | *on: pw.ColumnExpression, |
| 584 | behavior: CommonBehavior | None = None, |
| 585 | how: pw.JoinMode = pw.JoinMode.INNER, |
| 586 | left_instance: pw.ColumnReference | None = None, |
| 587 | right_instance: pw.ColumnReference | None = None, |
| 588 | ) -> IntervalJoinResult: |
| 589 | """Performs an interval join of self with other using a time difference |
| 590 | and join expressions. If `self_time + lower_bound <= |
| 591 | other_time <= self_time + upper_bound` |
| 592 | and conditions in `on` are satisfied, the rows are joined. |
| 593 | |
| 594 | Args: |
| 595 | other: the right side of a join. |
| 596 | self_time (pw.ColumnExpression[int | float | datetime]): |
| 597 | time expression in self. |
| 598 | other_time (pw.ColumnExpression[int | float | datetime]): |
| 599 | time expression in other. |
| 600 | lower_bound: a lower bound on time difference between other_time |
| 601 | and self_time. |
| 602 | upper_bound: an upper bound on time difference between other_time |
| 603 | and self_time. |
| 604 | on: a list of column expressions. Each must have == as the top level |
| 605 | operation and be of the form LHS: ColumnReference == RHS: ColumnReference. |
| 606 | behavior: defines a temporal behavior of a join - features like delaying entries |
| 607 | or ignoring late entries. You can see examples below or read more in the |
| 608 | `temporal behavior of interval join tutorial </developers/user-guide/temporal-data/temporal_behavior>`_ . |
| 609 | how: decides whether to run `interval_join_inner`, `interval_join_left`, `interval_join_right` |
| 610 | or `interval_join_outer`. Default is INNER. |
| 611 | left_instance/right_instance: optional arguments describing partitioning of the data into separate instances |
| 612 | |
| 613 | Returns: |
| 614 | IntervalJoinResult: a result of the interval join. A method `.select()` |
| 615 | can be called on it to extract relevant columns from the result of a join. |
| 616 | |
| 617 | Examples: |
| 618 | |
| 619 | >>> import pathway as pw |
| 620 | >>> t1 = pw.debug.table_from_markdown( |
| 621 | ... ''' |
| 622 | ... | t |
| 623 | ... 1 | 3 |
| 624 | ... 2 | 4 |
| 625 | ... 3 | 5 |
| 626 | ... 4 | 11 |
| 627 | ... ''' |
| 628 | ... ) |
| 629 | >>> t2 = pw.debug.table_from_markdown( |
| 630 | ... ''' |
| 631 | ... | t |
| 632 | ... 1 | 0 |
| 633 | ... 2 | 1 |
| 634 | ... 3 | 4 |