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)
| 292 | /// consistent and avoids mixing native sqlparser AS-OF support with custom |
| 293 | /// preprocessing in the same pipeline. |
| 294 | fn 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` |
no test coverage detected