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

Function strip_as_of_valid_time

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

Match `AS OF VALID TIME ` (case-insensitive) anywhere in `sql` and strip it. Same expression forms as `strip_as_of_system_time`. Returns `None` if the clause is absent.

(sql: &str)

Source from the content-addressed store, hash-verified

309/// strip it. Same expression forms as `strip_as_of_system_time`. Returns `None`
310/// if the clause is absent.
311fn strip_as_of_valid_time(sql: &str) -> Result<Option<(String, i64)>, TemporalParseError> {
312 let keyword = "AS OF VALID TIME";
313 let Some(start) = keyword_position_outside_literals(sql, keyword) else {
314 return Ok(None);
315 };
316 let after_kw = start + keyword.len();
317 let (ms, end_abs) = parse_as_of_expr(sql, after_kw)?;
318 let mut out = String::with_capacity(sql.len());
319 out.push_str(sql[..start].trim_end());
320 out.push(' ');
321 out.push_str(sql[end_abs..].trim_start());
322 Ok(Some((out.trim().to_string(), ms)))
323}
324
325/// Extract the temporal expression that follows an AS-OF keyword at `offset`
326/// in `sql`. Returns `(resolved_ms, end_offset_exclusive)`.

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