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

Method execute_set_operation

graphlite/src/exec/executor.rs:6898–6959  ·  view source on GitHub ↗

Execute set operation (UNION, INTERSECT, EXCEPT)

(
        &self,
        set_op: &crate::ast::SetOperation,
        context: &mut ExecutionContext,
    )

Source from the content-addressed store, hash-verified

6896
6897 /// Execute set operation (UNION, INTERSECT, EXCEPT)
6898 fn execute_set_operation(
6899 &self,
6900 set_op: &crate::ast::SetOperation,
6901 context: &mut ExecutionContext,
6902 ) -> Result<QueryResult, ExecutionError> {
6903 log::debug!("=== EXECUTE_SET_OPERATION CALLED");
6904 log::debug!("Operation: {:?}", set_op.operation);
6905
6906 // Execute left and right queries
6907 let left_result = self.execute_query_recursive(&set_op.left, context)?;
6908 let right_result = self.execute_query_recursive(&set_op.right, context)?;
6909
6910 log::debug!(
6911 "Left result: {} rows, Right result: {} rows",
6912 left_result.rows.len(),
6913 right_result.rows.len()
6914 );
6915
6916 // Validate column compatibility
6917 self.validate_set_operation_compatibility(&left_result, &right_result)?;
6918
6919 // Execute the appropriate set operation
6920 let mut result = match set_op.operation {
6921 crate::ast::SetOperationType::Union => {
6922 self.execute_union(left_result, right_result, false)
6923 } // UNION removes duplicates
6924 crate::ast::SetOperationType::UnionAll => {
6925 self.execute_union(left_result, right_result, true)
6926 } // UNION ALL keeps duplicates
6927 crate::ast::SetOperationType::Intersect => {
6928 self.execute_intersect(left_result, right_result, true)
6929 }
6930 crate::ast::SetOperationType::IntersectAll => {
6931 self.execute_intersect(left_result, right_result, false)
6932 }
6933 crate::ast::SetOperationType::Except => {
6934 self.execute_except(left_result, right_result, true)
6935 }
6936 crate::ast::SetOperationType::ExceptAll => {
6937 self.execute_except(left_result, right_result, false)
6938 }
6939 }?;
6940
6941 // Apply ORDER BY if present (not implemented yet)
6942 if let Some(_order_clause) = &set_op.order_clause {
6943 log::debug!("WARNING: ORDER BY on set operations not yet implemented");
6944 }
6945
6946 // Apply LIMIT if present
6947 if let Some(ref limit_clause) = set_op.limit_clause {
6948 let offset = limit_clause.offset.unwrap_or(0);
6949
6950 result.rows = result
6951 .rows
6952 .into_iter()
6953 .skip(offset)
6954 .take(limit_clause.count)
6955 .collect();

Callers 3

execute_statementMethod · 0.80

Calls 6

execute_unionMethod · 0.80
execute_intersectMethod · 0.80
execute_exceptMethod · 0.80
skipMethod · 0.45

Tested by

no test coverage detected