Extract a non-negative integer from a function argument expression.
(expr: &ast::Expr, option: &str)
| 227 | |
| 228 | /// Extract a non-negative integer from a function argument expression. |
| 229 | fn extract_u64(expr: &ast::Expr, option: &str) -> Result<u64> { |
| 230 | match expr { |
| 231 | ast::Expr::Value(v) => match &v.value { |
| 232 | ast::Value::Number(n, _) => n.parse::<u64>().map_err(|_| SqlError::Unsupported { |
| 233 | detail: format!("ANN option '{option}' expects a non-negative integer, got: {n}"), |
| 234 | }), |
| 235 | _ => Err(SqlError::Unsupported { |
| 236 | detail: format!( |
| 237 | "ANN option '{option}' expects a non-negative integer, got: {expr}" |
| 238 | ), |
| 239 | }), |
| 240 | }, |
| 241 | _ => Err(SqlError::Unsupported { |
| 242 | detail: format!("ANN option '{option}' expects a non-negative integer, got: {expr}"), |
| 243 | }), |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | /// Extract a float from a function argument expression. |
| 248 | fn extract_f64(expr: &ast::Expr, option: &str) -> Result<f64> { |