Execute a SELECT statement with specific graph Internal method for select statements with graph
(
&self,
select_stmt: &crate::ast::SelectStatement,
graph: &Arc<GraphCache>,
context: &mut ExecutionContext,
)
| 3132 | /// Execute a SELECT statement with specific graph |
| 3133 | /// Internal method for select statements with graph |
| 3134 | fn execute_select_statement_with_graph( |
| 3135 | &self, |
| 3136 | select_stmt: &crate::ast::SelectStatement, |
| 3137 | graph: &Arc<GraphCache>, |
| 3138 | context: &mut ExecutionContext, |
| 3139 | ) -> Result<QueryResult, ExecutionError> { |
| 3140 | // If there's a FROM clause, validate it |
| 3141 | if let Some(from_clause) = &select_stmt.from_clause { |
| 3142 | if from_clause.graph_expressions.is_empty() { |
| 3143 | return Err(ExecutionError::SyntaxError( |
| 3144 | "FROM clause must specify at least one graph expression".to_string(), |
| 3145 | )); |
| 3146 | } |
| 3147 | } |
| 3148 | // If no FROM clause, we're using the provided graph (from session) |
| 3149 | |
| 3150 | // Extract the MATCH clause from the FROM clause if present |
| 3151 | let match_clause = if let Some(from_clause) = &select_stmt.from_clause { |
| 3152 | if let Some(first_graph_expr) = from_clause.graph_expressions.first() { |
| 3153 | first_graph_expr.match_statement.clone() |
| 3154 | } else { |
| 3155 | None |
| 3156 | } |
| 3157 | } else { |
| 3158 | None |
| 3159 | }; |
| 3160 | |
| 3161 | // If no MATCH clause in FROM, we need to create a simple MATCH for all nodes |
| 3162 | let match_clause = match_clause.unwrap_or_else(|| { |
| 3163 | crate::ast::MatchClause { |
| 3164 | patterns: vec![crate::ast::PathPattern { |
| 3165 | assignment: None, // No path assignment |
| 3166 | path_type: None, // Default path type |
| 3167 | elements: vec![crate::ast::PatternElement::Node(crate::ast::Node { |
| 3168 | identifier: Some("n".to_string()), |
| 3169 | labels: vec![], |
| 3170 | properties: None, |
| 3171 | location: crate::ast::Location::default(), |
| 3172 | })], |
| 3173 | location: crate::ast::Location::default(), |
| 3174 | }], |
| 3175 | location: crate::ast::Location::default(), |
| 3176 | } |
| 3177 | }); |
| 3178 | |
| 3179 | // Create a Query from the SELECT statement components |
| 3180 | let query = crate::ast::Query::Basic(crate::ast::BasicQuery { |
| 3181 | match_clause, |
| 3182 | where_clause: select_stmt.where_clause.clone(), |
| 3183 | return_clause: crate::ast::ReturnClause { |
| 3184 | distinct: select_stmt.distinct.clone(), |
| 3185 | items: self.expand_select_items(&select_stmt.return_items, graph)?, |
| 3186 | location: crate::ast::Location::default(), |
| 3187 | }, |
| 3188 | group_clause: select_stmt.group_clause.clone(), |
| 3189 | having_clause: select_stmt.having_clause.clone(), |
| 3190 | order_clause: select_stmt.order_clause.clone(), |
| 3191 | limit_clause: select_stmt.limit_clause.clone(), |
no test coverage detected