MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / strip_as_of_system_time

Function strip_as_of_system_time

nodedb-sql/src/parser/preprocess/temporal.rs:294–306  ·  view source on GitHub ↗

Match `AS OF SYSTEM TIME ` (case-insensitive) anywhere in `sql` and strip it. The expression may be an integer literal, `NOW()`, or an ISO-8601 timestamp string. Returns `None` if the clause is absent. This is the CockroachDB-inspired form used on array read queries. It is parsed by NodeDB's pre-processor (option b — string-based extraction before sqlparser-rs sees the statement) because sq

(sql: &str)

Source from the content-addressed store, hash-verified

292/// consistent and avoids mixing native sqlparser AS-OF support with custom
293/// preprocessing in the same pipeline.
294fn strip_as_of_system_time(sql: &str) -> Result<Option<(String, i64)>, TemporalParseError> {
295 let keyword = "AS OF SYSTEM TIME";
296 let Some(start) = keyword_position_outside_literals(sql, keyword) else {
297 return Ok(None);
298 };
299 let after_kw = start + keyword.len();
300 let (ms, end_abs) = parse_as_of_expr(sql, after_kw)?;
301 let mut out = String::with_capacity(sql.len());
302 out.push_str(sql[..start].trim_end());
303 out.push(' ');
304 out.push_str(sql[end_abs..].trim_start());
305 Ok(Some((out.trim().to_string(), ms)))
306}
307
308/// Match `AS OF VALID TIME <expr>` (case-insensitive) anywhere in `sql` and
309/// strip it. Same expression forms as `strip_as_of_system_time`. Returns `None`

Callers 1

extractFunction · 0.85

Calls 5

parse_as_of_exprFunction · 0.85
to_stringMethod · 0.80
lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected