As-of align
analytics_alignAlign two stored time series with an as-of join to line up different frequencies, keeping each left row and matching the latest or next right row within an optional tolerance.
Instructions
As-of join of two stored time series, computed locally in DuckDB (ASOF LEFT JOIN): every left row is kept and gets the right row that is the latest at or before its time (direction backward) or the first at or after it (forward), optionally within a tolerance (ISO-8601 duration, e.g. PT5M) and within the same by value (e.g. ticker). Output: the left columns, the chosen right columns (names that collide get the suffix, default _right) and matched_t, the matched right row's time; unmatched right values are None (no_match). Use it to line up series of different frequencies. Large outputs are stored and you get a result_id.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| by | No | Column present in both results to match within (e.g. ticker). | |
| suffix | No | Added to right column names that collide. | _right |
| direction | No | backward: the latest right row at or before the left time; forward: the first at or after. | backward |
| tolerance | No | Largest allowed time gap as an ISO-8601 duration (PT30S, PT5M, P1D); none by default. | |
| right_columns | No | Right columns to bring over. Default: every right column except its time, by and absent. | |
| left_result_id | Yes | The stored time series whose rows are kept (one output row per left row). | |
| right_result_id | Yes | The stored time series matched to each left row. |