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

Function extract_subqueries

nodedb-sql/src/planner/subquery.rs:49–61  ·  view source on GitHub ↗

Extract `IN (SELECT ...)` and `NOT IN (SELECT ...)` patterns from a WHERE clause. Returns the extracted subquery joins and the remaining WHERE expression (with subquery predicates removed). If the entire WHERE is a single subquery predicate, `remaining_where` is `None`.

(
    expr: &Expr,
    catalog: &dyn SqlCatalog,
    functions: &FunctionRegistry,
    temporal: crate::TemporalScope,
)

Source from the content-addressed store, hash-verified

47/// (with subquery predicates removed). If the entire WHERE is a single
48/// subquery predicate, `remaining_where` is `None`.
49pub fn extract_subqueries(
50 expr: &Expr,
51 catalog: &dyn SqlCatalog,
52 functions: &FunctionRegistry,
53 temporal: crate::TemporalScope,
54) -> Result<SubqueryExtraction> {
55 let mut joins = Vec::new();
56 let remaining = extract_recursive(expr, &mut joins, catalog, functions, temporal)?;
57 Ok(SubqueryExtraction {
58 joins,
59 remaining_where: remaining,
60 })
61}
62
63/// Recursively walk the WHERE expression, extracting subquery predicates.
64///

Callers 2

plan_join_from_selectFunction · 0.85
plan_selectFunction · 0.85

Calls 1

extract_recursiveFunction · 0.85

Tested by

no test coverage detected