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

Method execute_unwind_statement

graphlite/src/exec/executor.rs:7525–7558  ·  view source on GitHub ↗

Execute UNWIND statement: UNWIND expression AS variable

(
        &self,
        unwind_stmt: &crate::ast::UnwindStatement,
        context: &mut ExecutionContext,
    )

Source from the content-addressed store, hash-verified

7523
7524 /// Execute UNWIND statement: UNWIND expression AS variable
7525 fn execute_unwind_statement(
7526 &self,
7527 unwind_stmt: &crate::ast::UnwindStatement,
7528 context: &mut ExecutionContext,
7529 ) -> Result<QueryResult, ExecutionError> {
7530 use crate::storage::Value;
7531
7532 // Evaluate the expression to get a list using the passed context
7533 let list_value = self.evaluate_expression(&unwind_stmt.expression, context)?;
7534
7535 // The expression should evaluate to a list
7536 let items = match list_value {
7537 Value::List(items) => items,
7538 _ => {
7539 return Err(ExecutionError::RuntimeError(format!(
7540 "UNWIND expression must evaluate to a list, got: {:?}",
7541 list_value
7542 )));
7543 }
7544 };
7545
7546 // Create a result set with one row per item in the list
7547 let mut result = QueryResult::new();
7548 result.variables.push(unwind_stmt.variable.clone());
7549
7550 for item in items {
7551 let mut row = Row::new();
7552 row.add_value(unwind_stmt.variable.clone(), item.clone());
7553 row.positional_values.push(item);
7554 result.rows.push(row);
7555 }
7556
7557 Ok(result)
7558 }
7559
7560 /// Validate that two query results have compatible schemas for set operations
7561 fn validate_set_operation_compatibility(

Callers 3

execute_statementMethod · 0.80

Calls 3

cloneMethod · 0.80
add_valueMethod · 0.80
evaluate_expressionMethod · 0.45

Tested by

no test coverage detected