Expand description
§ASOF Join Operators
Implementation of temporal proximity joins that match events based on closest timestamp rather than exact equality.
ASOF joins are essential for financial and time-series applications where you need to enrich events with the most recent prior data (e.g., enriching trades with the most recent quote).
§Join Directions
- Backward: Match with the most recent prior event (default for finance)
- Forward: Match with the next future event
- Nearest: Match with the closest event by absolute time difference
§Example
use laminar_core::operator::asof_join::{
AsofJoinOperator, AsofJoinConfig, AsofDirection, AsofJoinType,
};
use std::time::Duration;
// Join trades with the most recent quote within 5 seconds
let config = AsofJoinConfig {
key_column: "symbol".to_string(),
left_time_column: "trade_time".to_string(),
right_time_column: "quote_time".to_string(),
direction: AsofDirection::Backward,
tolerance: Some(Duration::from_secs(5)),
join_type: AsofJoinType::Inner,
operator_id: Some("trade_quote_join".to_string()),
};
let operator = AsofJoinOperator::new(config);§SQL Syntax (Future)
SELECT t.*, q.bid, q.ask
FROM trades t
ASOF JOIN quotes q
ON t.symbol = q.symbol
AND t.trade_time >= q.quote_time
AND t.trade_time - q.quote_time <= INTERVAL '5' SECOND;§State Management
Right-side events are stored in per-key BTreeMap structures for O(log n)
temporal lookups. State is cleaned up based on watermark progress.
Structs§
- Asof
Join Config - Configuration for an ASOF join operator.
- Asof
Join Config Builder - Builder for
AsofJoinConfig. - Asof
Join Metrics - Metrics for tracking ASOF join operations.
- Asof
Join Operator - ASOF join operator.
- AsofRow
- A stored right-side event for ASOF matching.
- KeyState
- Per-key state for ASOF joining.
Enums§
- Asof
Direction - Direction for ASOF matching.
- Asof
Join Type - Type of ASOF join to perform.