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

Function _assign_sliding_windows

python/pathway/stdlib/temporal/_window.py:818–842  ·  view source on GitHub ↗
(
    self: pw.Table,
    key: pw.ColumnExpression,
    instance: pw.ColumnExpression | None,
    *,
    window: clmn.SlidingWindow,
    with_original_id: bool = False,
)

Source from the content-addressed store, hash-verified

816
817
818def _assign_sliding_windows(
819 self: pw.Table,
820 key: pw.ColumnExpression,
821 instance: pw.ColumnExpression | None,
822 *,
823 window: clmn.SlidingWindow,
824 with_original_id: bool = False,
825) -> pw.Table:
826 # The window assignment performed in the engine reindexes the rows, so we have
827 # to capture the original row id beforehand for the windowed groupby to use it.
828 if with_original_id:
829 updated = self.with_columns(
830 _pw_key=key, _pw_instance=instance, _pw_original_id=self.id
831 )
832 else:
833 updated = self.with_columns(_pw_key=key, _pw_instance=instance)
834 result = _assign_sliding_windows_internal(updated, window=window)
835 if window.origin is not None:
836 result = result.filter(pw.this._pw_window_start >= window.origin)
837 result = result.with_columns(
838 _pw_window=pw.make_tuple(
839 pw.this._pw_instance, pw.this._pw_window_start, pw.this._pw_window_end
840 )
841 )
842 return result
843
844
845@desugar

Callers 2

_applyMethod · 0.85
_joinMethod · 0.85

Calls 3

with_columnsMethod · 0.80
filterMethod · 0.45

Tested by

no test coverage detected