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

Function extract_float

nodedb-sql/src/planner/select/helpers.rs:167–186  ·  view source on GitHub ↗
(expr: &ast::Expr)

Source from the content-addressed store, hash-verified

165}
166
167pub fn extract_float(expr: &ast::Expr) -> Result<f64> {
168 match expr {
169 ast::Expr::Value(v) => match &v.value {
170 ast::Value::Number(n, _) => n.parse::<f64>().map_err(|_| SqlError::TypeMismatch {
171 detail: format!("expected number: {n}"),
172 }),
173 _ => Err(SqlError::TypeMismatch {
174 detail: format!("expected number, got: {expr}"),
175 }),
176 },
177 // Handle negative numbers: -73.9855 is parsed as UnaryOp { Minus, 73.9855 }
178 ast::Expr::UnaryOp {
179 op: ast::UnaryOperator::Minus,
180 expr: inner,
181 } => extract_float(inner).map(|f| -f),
182 _ => Err(SqlError::TypeMismatch {
183 detail: format!("expected number, got: {expr}"),
184 }),
185 }
186}
187
188/// Map a vector distance function name to its `DistanceMetric`.
189///

Callers 7

plan_spatial_from_whereFunction · 0.85
extract_geometry_argFunction · 0.85
extract_float_arrayFunction · 0.85
plan_hybrid_two_sourceFunction · 0.85
plan_hybrid_tripleFunction · 0.85
extract_graph_score_argsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected