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

Function _Validate_apply_all_operator

src/ast/ast_validations.c:551–580  ·  view source on GitHub ↗

validate an apply-all operator

Source from the content-addressed store, hash-verified

549
550// validate an apply-all operator
551static VISITOR_STRATEGY _Validate_apply_all_operator
552(
553 const cypher_astnode_t *n, // ast-node
554 bool start, // first traversal
555 ast_visitor *visitor // visitor
556) {
557 validations_ctx *vctx = AST_Visitor_GetContext(visitor);
558 if(!start) {
559 return VISITOR_CONTINUE;
560 }
561
562 // Working with a function call that has * as its argument.
563 const cypher_astnode_t *func = cypher_ast_apply_all_operator_get_func_name(n);
564 const char *func_name = cypher_ast_function_name_get_value(func);
565
566 // Verify that this is a COUNT call.
567 if(strcasecmp(func_name, "COUNT")) {
568 ErrorCtx_SetError("COUNT is the only function which can accept * as an argument");
569 return VISITOR_BREAK;
570 }
571
572 // Verify that DISTINCT is not specified.
573 if(cypher_ast_apply_all_operator_get_distinct(n)) {
574 // TODO consider opening a parser error, this construction is invalid in Neo's parser.
575 ErrorCtx_SetError("Cannot specify both DISTINCT and * in COUNT(DISTINCT *)");
576 return VISITOR_BREAK;
577 }
578
579 return VISITOR_RECURSE;
580}
581
582// validate an apply operator
583static VISITOR_STRATEGY _Validate_apply_operator

Callers

nothing calls this directly

Calls 2

AST_Visitor_GetContextFunction · 0.85
ErrorCtx_SetErrorFunction · 0.85

Tested by

no test coverage detected