MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / AST_RewriteStarProjections

Function AST_RewriteStarProjections

src/ast/ast_rewrite_star_projections.c:293–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291}
292
293bool AST_RewriteStarProjections
294(
295 const cypher_astnode_t *root // root for which to rewrite star projections
296) {
297 bool rewritten = false;
298
299 if(cypher_astnode_type(root) != CYPHER_AST_QUERY) {
300 return false;
301 }
302
303 // rewrite all WITH * / RETURN * clauses to include all aliases
304 uint scope_start = 0;
305 uint clause_count = cypher_ast_query_nclauses(root);
306
307 for(uint i = 0; i < clause_count; i ++) {
308 const cypher_astnode_t *clause = cypher_ast_query_get_clause(root, i);
309 cypher_astnode_type_t t = cypher_astnode_type(clause);
310
311 if(t == CYPHER_AST_CALL_SUBQUERY) {
312 rewritten |=
313 _rewrite_call_subquery_star_projections(root, scope_start, i);
314 continue;
315 }
316
317 if(t != CYPHER_AST_WITH && t != CYPHER_AST_RETURN) {
318 continue;
319 }
320
321 bool has_include_existing = (t == CYPHER_AST_WITH) ?
322 cypher_ast_with_has_include_existing(clause) :
323 cypher_ast_return_has_include_existing(clause);
324
325 if(has_include_existing) {
326 // clause contains a star projection, replace it
327 replace_clause((cypher_astnode_t *)root, (cypher_astnode_t *)clause,
328 scope_start, i, NULL);
329 rewritten = true;
330 }
331
332 // update scope start
333 scope_start = i;
334 }
335
336 return rewritten;
337}
338

Callers 2

parse_queryFunction · 0.85

Calls 2

replace_clauseFunction · 0.85

Tested by

no test coverage detected