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

Function extract_frame_offset

nodedb-sql/src/planner/window/frame.rs:86–96  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

84/// literal that fails to parse) is rejected at plan time rather than silently
85/// truncated.
86fn 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)]
99mod tests {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected