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

Method execute_call_statement_without_graph

graphlite/src/exec/executor.rs:3035–3118  ·  view source on GitHub ↗

Execute a CALL statement with specific graph Execute a call statement without any graph context (for graph-independent procedures) Internal method for call statements without graph

(
        &self,
        call_stmt: &crate::ast::CallStatement,
        context: &ExecutionContext,
        session_id: Option<&str>,
    )

Source from the content-addressed store, hash-verified

3033 /// Execute a call statement without any graph context (for graph-independent procedures)
3034 /// Internal method for call statements without graph
3035 fn execute_call_statement_without_graph(
3036 &self,
3037 call_stmt: &crate::ast::CallStatement,
3038 context: &ExecutionContext,
3039 session_id: Option<&str>,
3040 ) -> Result<QueryResult, ExecutionError> {
3041 // Evaluate arguments using the passed context
3042 let mut evaluated_args = Vec::new();
3043
3044 for arg in &call_stmt.arguments {
3045 let value = self.evaluate_expression(arg, context)?;
3046 evaluated_args.push(value);
3047 }
3048
3049 // Execute the system procedure with the actual session_id
3050 let mut result = self.system_procedures.execute_procedure(
3051 &call_stmt.procedure_name,
3052 evaluated_args,
3053 session_id,
3054 )?;
3055
3056 // If there's a YIELD clause, filter the columns
3057 if let Some(yield_clause) = &call_stmt.yield_clause {
3058 for row in &mut result.rows {
3059 let mut filtered_values = std::collections::HashMap::new();
3060
3061 for yield_item in &yield_clause.items {
3062 let column_name = &yield_item.column_name;
3063 let output_name = yield_item.alias.as_ref().unwrap_or(column_name);
3064
3065 if let Some(value) = row.values.get(column_name) {
3066 filtered_values.insert(output_name.clone(), value.clone());
3067 }
3068 }
3069
3070 row.values = filtered_values;
3071 }
3072
3073 // Update column list
3074 result.variables = yield_clause
3075 .items
3076 .iter()
3077 .map(|item| item.alias.as_ref().unwrap_or(&item.column_name).clone())
3078 .collect();
3079 }
3080
3081 // Apply WHERE clause filtering after YIELD (per ISO GQL standard)
3082 if let Some(where_clause) = &call_stmt.where_clause {
3083 let filtered_rows: Result<Vec<_>, ExecutionError> = result
3084 .rows
3085 .into_iter()
3086 .filter_map(|row| {
3087 // Clone the passed context and add row variables for WHERE evaluation
3088 let mut temp_context = context.clone();
3089 for (key, value) in &row.values {
3090 temp_context.variables.insert(key.clone(), value.clone());
3091 }
3092

Calls 6

execute_procedureMethod · 0.80
cloneMethod · 0.80
evaluate_expressionMethod · 0.45
getMethod · 0.45
insertMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected