Expand description
Extract and strip NodeDB-specific bitemporal clauses before sqlparser sees the statement.
Supported forms (case-insensitive, whitespace-tolerant):
-- Table scan style (existing):
SELECT ... FROM t FOR SYSTEM_TIME AS OF 1700000000000 WHERE ...
SELECT ... FROM t FOR VALID_TIME CONTAINS 1700000000000 WHERE ...
SELECT ... FROM t FOR VALID_TIME FROM 1700000000000 TO 1700001000000 WHERE ...
-- Array read style (CockroachDB-inspired, two orthogonal clauses):
SELECT ... FROM array_slice(...) AS OF SYSTEM TIME 1700000000000
SELECT ... FROM array_slice(...) AS OF VALID TIME 1700000000000
SELECT ... FROM array_slice(...) AS OF SYSTEM TIME 1700000000000 AS OF VALID TIME 1700000001000A function-form escape hatch is also accepted, anywhere in the statement, for pgwire drivers that reject non-standard clauses:
SELECT __system_as_of__(1700000000000) FROM t WHERE ...All recognised clauses are extracted once per statement. Repeated clauses
of the same kind return Err; conflicting valid-time forms (CONTAINS +
FROM/TO) return Err.
Timestamps are milliseconds since Unix epoch. Accepted expression forms:
- Integer literal (milliseconds since epoch)
NOW()— resolved to the current wall-clock millisecond- ISO-8601 / RFC-3339 timestamp string
'2024-01-15T00:00:00Z'
Any other expression form is rejected with a typed TemporalParseError
naming the unsupported form.
Structs§
- Extracted
- Output of the temporal preprocess stage.
- Temporal
Parse Error - Error shape — surfaced as
SqlError::Parseby the caller.
Functions§
- extract
- Strip temporal clauses from
sqland return the rewritten text plus the extractedTemporalScope. ReturnsOk(None)when no temporal clause is present so the caller can short-circuit to the existing pipeline.