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)
| 309 | /// strip it. Same expression forms as `strip_as_of_system_time`. Returns `None` |
| 310 | /// if the clause is absent. |
| 311 | fn 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)`. |
no test coverage detected