Skip to main content

resolve_as_of

Function resolve_as_of 

Source
pub fn resolve_as_of(db: &Db, marker: u64) -> Result<u64, String>
Expand description

Resolve an AS OF marker to a real sequence number.

A bare integer passes through bit-for-bit; that is the backcompat contract. A wall-clock moment arrives with WALL_CLOCK_FLAG set and is resolved through Db::seq_at — the last sequence whose write-time is at or before the moment.

§Why this is a function and not a closure in one executor

It WAS a closure inside the SQL executor, and NQL had no resolution at all. That split is why FROM orders AS OF "2026-01-01" errored in Rust while the Python reference engine accepted it: one dialect, two implementations, and only one of them taught to read a timestamp.

Worse than the error was the fix that looked obvious — teaching the NQL PARSER to accept a datetime without also teaching its executor to resolve the flag. The marker would then reach get_as_of as a literal sequence near 2^63 and the query would answer confidently from the wrong point in history. An error is recoverable; a silently wrong answer about the past is the failure this codebase exists to prevent.

Returns the message TEXT rather than a typed error because the two callers surface it differently (a wire ErrorResponse and an anyhow bail), and both would convert a shared enum straight back to a string.