From 27a03975b8fe9faa214121354f49d846f379a819 Mon Sep 17 00:00:00 2001 From: jimingquan Date: Fri, 22 Apr 2022 16:46:22 +0800 Subject: [PATCH 1/2] check maximum length of variable length relationship --- src/graph/validator/MatchValidator.cpp | 3 +++ .../features/match/VariableLengthPattern.feature | 15 +++++++++++++++ 2 files changed, 18 insertions(+) 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: From 5e63b72132144ddff2b1f9d3ca6843c35a9ef74e Mon Sep 17 00:00:00 2001 From: jimingquan Date: Sun, 24 Apr 2022 11:38:46 +0800 Subject: [PATCH 2/2] fix test error --- tests/tck/features/match/ZeroStep.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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: