Parse a frame offset from a literal. Only non-negative integer literals that fit in a `u64` are accepted; anything else (expression, float, oversized literal that fails to parse) is rejected at plan time rather than silently truncated.
(expr: &ast::Expr)
| 84 | /// literal that fails to parse) is rejected at plan time rather than silently |
| 85 | /// truncated. |
| 86 | fn extract_frame_offset(expr: &ast::Expr) -> Result<u64> { |
| 87 | if let ast::Expr::Value(v) = expr |
| 88 | && let ast::Value::Number(n, _) = &v.value |
| 89 | && let Ok(parsed) = n.parse::<u64>() |
| 90 | { |
| 91 | return Ok(parsed); |
| 92 | } |
| 93 | Err(SqlError::Unsupported { |
| 94 | detail: format!("window frame offset must be a non-negative integer literal, got {expr}"), |
| 95 | }) |
| 96 | } |
| 97 | |
| 98 | #[cfg(test)] |
| 99 | mod tests { |
no outgoing calls
no test coverage detected