Skip to main content

Module interval_rewriter

Module interval_rewriter 

Source
Expand description

INTERVAL arithmetic rewriter for BIGINT timestamp columns Interval arithmetic rewriter for BIGINT timestamp columns.

LaminarDB uses BIGINT millisecond timestamps for event time. DataFusion cannot natively evaluate Int64 ± INTERVAL, so this module rewrites INTERVAL expressions in arithmetic operations to equivalent millisecond integer literals before the SQL reaches DataFusion.

§Example

-- Before rewrite:
SELECT * FROM trades t
INNER JOIN orders o ON t.symbol = o.symbol
  AND o.ts BETWEEN t.ts - INTERVAL '10' SECOND AND t.ts + INTERVAL '10' SECOND

-- After rewrite:
SELECT * FROM trades t
INNER JOIN orders o ON t.symbol = o.symbol
  AND o.ts BETWEEN t.ts - 10000 AND t.ts + 10000

Functions§

rewrite_expr_mut
Rewrite INTERVAL arithmetic in an expression tree, in place.
rewrite_interval_arithmetic
Rewrite all INTERVAL arithmetic in a SQL [Statement].