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

Function extract_equality_with_residual

nodedb-sql/src/engine_rules/mod.rs:294–309  ·  view source on GitHub ↗

Pull `(column_name, equality_value, residual_expr)` out of a filter expression if it contains a column-equals-literal predicate that can drive an index lookup. Returns `None` if no usable equality is present. The returned residual is the rest of the conjunction with the equality removed — `None` when the filter was a bare equality.

(
    expr: &FilterExpr,
)

Source from the content-addressed store, hash-verified

292/// present. The returned residual is the rest of the conjunction with
293/// the equality removed — `None` when the filter was a bare equality.
294fn extract_equality_with_residual(
295 expr: &FilterExpr,
296) -> Option<(String, SqlValue, Option<SqlExpr>)> {
297 match expr {
298 FilterExpr::Comparison {
299 field,
300 op: CompareOp::Eq,
301 value,
302 } => Some((field.clone(), value.clone(), None)),
303 FilterExpr::Expr(sql_expr) => {
304 let (col, lit, residual) = split_equality_from_expr(sql_expr)?;
305 Some((col, lit, residual))
306 }
307 _ => None,
308 }
309}
310
311/// Return `(column, literal, residual_expr)` for an equality found
312/// anywhere in a right-leaning AND conjunction tree, or `None` if no

Callers 1

Calls 2

split_equality_from_exprFunction · 0.85
cloneMethod · 0.45

Tested by

no test coverage detected