diff --git a/src/graph/validator/MatchValidator.cpp b/src/graph/validator/MatchValidator.cpp index 1e866090c38..c3ce1e5d23a 100644 --- a/src/graph/validator/MatchValidator.cpp +++ b/src/graph/validator/MatchValidator.cpp @@ -467,6 +467,9 @@ Status MatchValidator::validateAliases( Status MatchValidator::validateStepRange(const MatchStepRange *range) const { auto min = range->min(); auto max = range->max(); + if (max == std::numeric_limits::max()) { + return Status::SemanticError("Maximum hop for variable length relationship must be set"); + } if (min > max) { return Status::SemanticError( "Max hop must be greater equal than min hop: %ld vs. %ld", max, min); diff --git a/tests/tck/features/match/VariableLengthPattern.feature b/tests/tck/features/match/VariableLengthPattern.feature index 8d3b26edf05..2ecbfe14fa3 100644 --- a/tests/tck/features/match/VariableLengthPattern.feature +++ b/tests/tck/features/match/VariableLengthPattern.feature @@ -346,6 +346,21 @@ Feature: Variable length Pattern match (m to n) RETURN p """ Then a SemanticError should be raised at runtime: Alias used but not defined: `e' + When executing query: + """ + Match (a:player{name:"Tim Duncan"})-[e:like*]-(b) return b + """ + Then a SemanticError should be raised at runtime: Maximum hop for variable length relationship must be set + When executing query: + """ + Match (a:player{name:"Tim Duncan"})-[e:like*]->(b) return b + """ + Then a SemanticError should be raised at runtime: Maximum hop for variable length relationship must be set + When executing query: + """ + Match (a:player{name:"Tim Duncan"})<-[e:like*]-(b) return b + """ + Then a SemanticError should be raised at runtime: Maximum hop for variable length relationship must be set Scenario: Over expand end When executing query: diff --git a/tests/tck/features/match/ZeroStep.feature b/tests/tck/features/match/ZeroStep.feature index c85dbb619ef..ab67620efdb 100644 --- a/tests/tck/features/match/ZeroStep.feature +++ b/tests/tck/features/match/ZeroStep.feature @@ -455,10 +455,10 @@ Feature: Variable length Pattern match (0 step) | [[:like "Tony Parker"->"LaMarcus Aldridge" @0 {likeness: 90}]] | ("Trail Blazers" :team{name: "Trail Blazers"}) | | [] | ("Trail Blazers" :team{name: "Trail Blazers"}) | - Scenario: Multiple variable length with edge filter without max hop number + Scenario: Multiple variable length When executing query: """ - MATCH p=(v:player{name:"Tim Duncan"})-[e:like*1..]->(v2) + MATCH p=(v:player{name:"Tim Duncan"})-[e:like*1..100]->(v2) RETURN v2 AS Friends; """ Then the result should be, in any order: