MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / execute_basic_query_with_context

Method execute_basic_query_with_context

graphlite/src/exec/executor.rs:1010–1052  ·  view source on GitHub ↗

Execute a basic query with access to outer context variables (for correlated subqueries)

(
        &self,
        basic_query: &BasicQuery,
        outer_context: &ExecutionContext,
    )

Source from the content-addressed store, hash-verified

1008
1009 /// Execute a basic query with access to outer context variables (for correlated subqueries)
1010 fn execute_basic_query_with_context(
1011 &self,
1012 basic_query: &BasicQuery,
1013 outer_context: &ExecutionContext,
1014 ) -> Result<QueryResult, ExecutionError> {
1015 use crate::ast::{Document, Query, Statement};
1016 use crate::plan::optimizer::QueryPlanner;
1017
1018 log::debug!(
1019 "execute_basic_query_with_context: BasicQuery has GROUP BY: {}",
1020 basic_query.group_clause.is_some()
1021 );
1022
1023 // Get the graph from the execution context
1024 let graph = outer_context.current_graph.as_ref().ok_or_else(|| {
1025 ExecutionError::RuntimeError("No graph available in execution context".to_string())
1026 })?;
1027
1028 // Create a Document and Statement wrapper for the planner
1029 let query = Query::Basic(basic_query.clone());
1030 let statement = Statement::Query(query);
1031 let document = Document {
1032 statement,
1033 location: Location {
1034 line: 1,
1035 column: 1,
1036 offset: 0,
1037 },
1038 };
1039
1040 // Use the query planner to create a physical plan
1041 log::debug!("Calling QueryPlanner::plan_query");
1042 let mut planner = QueryPlanner::new();
1043 let planned_query = planner
1044 .plan_query(&document)
1045 .map_err(|e| ExecutionError::RuntimeError(format!("Planning error: {}", e)))?;
1046 log::debug!("QueryPlanner returned physical plan");
1047
1048 // Execute the physical plan with the graph from execution context
1049 // Create a mutable copy of the context for execution
1050 let mut context_copy = outer_context.clone();
1051 self.execute_with_provided_graph_and_audit(&planned_query, graph, &mut context_copy)
1052 }
1053
1054 /// Execute a subquery within the current execution context
1055 fn execute_subquery(

Calls 4

QueryEnum · 0.85
cloneMethod · 0.80
plan_queryMethod · 0.80

Tested by

no test coverage detected