diff --git a/src/graph/validator/FindPathValidator.cpp b/src/graph/validator/FindPathValidator.cpp index fbd6244f39a..6b45ae37467 100644 --- a/src/graph/validator/FindPathValidator.cpp +++ b/src/graph/validator/FindPathValidator.cpp @@ -37,15 +37,28 @@ Status FindPathValidator::validateWhere(WhereClause* where) { return Status::OK(); } // Not Support $-、$var、$$.tag.prop、$^.tag.prop、agg - auto expr = where->filter(); - if (ExpressionUtils::findAny(expr, + auto filterExpr = where->filter(); + if (ExpressionUtils::findAny(filterExpr, {Expression::Kind::kSrcProperty, Expression::Kind::kDstProperty, Expression::Kind::kVarProperty, Expression::Kind::kInputProperty})) { - return Status::SemanticError("Not support `%s' in where sentence.", expr->toString().c_str()); + return Status::SemanticError("Not support `%s' in where sentence.", + filterExpr->toString().c_str()); } - where->setFilter(ExpressionUtils::rewriteLabelAttr2EdgeProp(expr)); + + auto undefinedParams = graph::ExpressionUtils::ExtractInnerVars(filterExpr, qctx_); + if (!undefinedParams.empty()) { + return Status::SemanticError( + "Undefined parameters: " + + std::accumulate(++undefinedParams.begin(), + undefinedParams.end(), + *undefinedParams.begin(), + [](auto& lhs, auto& rhs) { return lhs + ", " + rhs; })); + } + auto* newFilter = graph::ExpressionUtils::rewriteParameter(filterExpr, qctx_); + + where->setFilter(ExpressionUtils::rewriteLabelAttr2EdgeProp(newFilter)); auto filter = where->filter(); auto typeStatus = deduceExprType(filter); diff --git a/tests/tck/features/yield/parameter.feature b/tests/tck/features/yield/parameter.feature index bb01c55ac0d..b5d589bad8d 100644 --- a/tests/tck/features/yield/parameter.feature +++ b/tests/tck/features/yield/parameter.feature @@ -274,6 +274,16 @@ Feature: Parameter GET SUBGRAPH FROM 'Tim Duncan' WHERE like.likeness < $unknown_distance YIELD edges as e """ Then a SemanticError should be raised at runtime: Undefined parameters: unknown_distance + When executing query: + """ + FIND ALL PATH FROM 'Tim Duncan' TO 'Tony Parker' OVER like WHERE like.likeness > $unknown_distance YIELD path as p + """ + Then a SemanticError should be raised at runtime: Undefined parameters: unknown_distance + When executing query: + """ + FIND SHORTEST PATH FROM 'Tim Duncan' TO 'Tony Parker' OVER like WHERE like.likeness > $unknown_distance YIELD path as p + """ + Then a SemanticError should be raised at runtime: Undefined parameters: unknown_distance When executing query: """ MATCH (v:player) RETURN v LIMIT $p6 @@ -358,6 +368,14 @@ Feature: Parameter | e | | [[:like "Tim Duncan"->"Manu Ginobili" @0 {likeness: 95}], [:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}], [:like "Dejounte Murray"->"Tim Duncan" @0 {likeness: 99}], [:like "Tony Parker"->"Tim Duncan" @0 {likeness: 95}]] | | [[:like "Tony Parker"->"Manu Ginobili" @0 {likeness: 95}], [:like "Dejounte Murray"->"Manu Ginobili" @0 {likeness: 99}], [:like "Dejounte Murray"->"Tony Parker" @0 {likeness: 99}]] | + When executing query: + """ + FIND ALL PATH FROM 'Tim Duncan' TO 'Tony Parker' OVER like WHERE like.likeness > $p10-1 YIELD path AS p + """ + Then the result should be, in any order: + | p | + | <("Tim Duncan")-[:like@0 {likeness: 95}]->("Tony Parker")> | + | <("Tim Duncan")-[:like@0 {likeness: 95}]->("Manu Ginobili")-[:like@0 {likeness: 90}]->("Tim Duncan")-[:like@0 {likeness: 95}]->("Tony Parker")> | Scenario: [param-test-013] DML Given an empty graph