diff --git a/src/graph/validator/FindPathValidator.cpp b/src/graph/validator/FindPathValidator.cpp index e46230701e5..4be5ca74b45 100644 --- a/src/graph/validator/FindPathValidator.cpp +++ b/src/graph/validator/FindPathValidator.cpp @@ -6,7 +6,6 @@ #include "graph/validator/FindPathValidator.h" -#include "common/expression/VariableExpression.h" #include "graph/planner/plan/Algo.h" #include "graph/planner/plan/Logic.h" #include "graph/util/ValidateUtil.h" diff --git a/src/graph/validator/GetSubgraphValidator.cpp b/src/graph/validator/GetSubgraphValidator.cpp index fd7cf6fb184..4be3f53cc7e 100644 --- a/src/graph/validator/GetSubgraphValidator.cpp +++ b/src/graph/validator/GetSubgraphValidator.cpp @@ -6,12 +6,6 @@ #include "graph/validator/GetSubgraphValidator.h" -#include - -#include "common/expression/UnaryExpression.h" -#include "common/expression/VariableExpression.h" -#include "common/expression/VertexExpression.h" -#include "graph/context/QueryExpressionContext.h" #include "graph/planner/plan/Logic.h" #include "graph/planner/plan/Query.h" #include "graph/util/ValidateUtil.h" diff --git a/src/graph/validator/test/FindPathValidatorTest.cpp b/src/graph/validator/test/FindPathValidatorTest.cpp index 980430b2371..84aff1c467e 100644 --- a/src/graph/validator/test/FindPathValidatorTest.cpp +++ b/src/graph/validator/test/FindPathValidatorTest.cpp @@ -18,10 +18,34 @@ class FindPathValidatorTest : public ValidatorTestBase { using PK = nebula::graph::PlanNode::Kind; +TEST_F(FindPathValidatorTest, invalidYield) { + { + std::string query = + "FIND SHORTEST PATH FROM \"Tim Duncan\" TO \"Tony Paker\" OVER * YIELD vertex"; + auto result = checkResult(query); + EXPECT_EQ(std::string(result.message()), + "SyntaxError: please add alias when using vertex. near `vertex'"); + } + { + std::string query = + "FIND ALL PATH WITH PROP FROM \"Tim Duncan\" TO \"Tony Paker\" OVER like YIELD edge as e"; + auto result = checkResult(query); + EXPECT_EQ(std::string(result.message()), "SemanticError: illegal yield clauses `EDGE AS e'"); + } + { + std::string query = + "FIND NOLOOP PATH WITH PROP FROM \"Tim Duncan\" TO \"Yao Ming\" OVER teammate YIELD path"; + auto result = checkResult(query); + EXPECT_EQ(std::string(result.message()), + "SyntaxError: please add alias when using path. near `path'"); + } +} + TEST_F(FindPathValidatorTest, SinglePairPath) { { std::string query = "FIND SHORTEST PATH FROM \"1\" TO \"2\" OVER like UPTO 5 STEPS"; std::vector expected = { + PK::kProject, PK::kDataCollect, PK::kLoop, PK::kStart, @@ -38,6 +62,7 @@ TEST_F(FindPathValidatorTest, SinglePairPath) { { std::string query = "FIND SHORTEST PATH FROM \"1\" TO \"2\" OVER like, serve UPTO 5 STEPS"; std::vector expected = { + PK::kProject, PK::kDataCollect, PK::kLoop, PK::kStart, @@ -57,6 +82,7 @@ TEST_F(FindPathValidatorTest, MultiPairPath) { { std::string query = "FIND SHORTEST PATH FROM \"1\" TO \"2\",\"3\" OVER like UPTO 5 STEPS"; std::vector expected = { + PK::kProject, PK::kDataCollect, PK::kLoop, PK::kCartesianProduct, @@ -78,6 +104,7 @@ TEST_F(FindPathValidatorTest, MultiPairPath) { "FIND SHORTEST PATH FROM \"1\",\"2\" TO \"3\",\"4\" OVER like UPTO 5 " "STEPS"; std::vector expected = { + PK::kProject, PK::kDataCollect, PK::kLoop, PK::kCartesianProduct, @@ -100,6 +127,7 @@ TEST_F(FindPathValidatorTest, ALLPath) { { std::string query = "FIND ALL PATH FROM \"1\" TO \"2\" OVER like UPTO 5 STEPS"; std::vector expected = { + PK::kProject, PK::kDataCollect, PK::kLoop, PK::kProject, @@ -118,6 +146,7 @@ TEST_F(FindPathValidatorTest, ALLPath) { { std::string query = "FIND ALL PATH FROM \"1\" TO \"2\",\"3\" OVER like UPTO 5 STEPS"; std::vector expected = { + PK::kProject, PK::kDataCollect, PK::kLoop, PK::kProject, @@ -142,6 +171,7 @@ TEST_F(FindPathValidatorTest, RunTimePath) { " | FIND SHORTEST PATH FROM $-.src TO $-.dst OVER like, serve UPTO 5 " "STEPS"; std::vector expected = { + PK::kProject, PK::kDataCollect, PK::kLoop, PK::kCartesianProduct, @@ -169,23 +199,12 @@ TEST_F(FindPathValidatorTest, RunTimePath) { "GO FROM \"1\" OVER like YIELD like._src AS src, like._dst AS dst " " | FIND ALL PATH FROM $-.src TO $-.dst OVER like, serve UPTO 5 STEPS"; std::vector expected = { - PK::kDataCollect, - PK::kLoop, - PK::kProject, - PK::kConjunctPath, - PK::kProject, - PK::kProduceAllPaths, - PK::kProduceAllPaths, - PK::kDedup, - PK::kGetNeighbors, - PK::kGetNeighbors, - PK::kProject, - PK::kPassThrough, - PK::kDedup, - PK::kStart, - PK::kProject, - PK::kProject, - PK::kGetNeighbors, + PK::kProject, PK::kDataCollect, PK::kLoop, + PK::kProject, PK::kConjunctPath, PK::kProject, + PK::kProduceAllPaths, PK::kProduceAllPaths, PK::kDedup, + PK::kGetNeighbors, PK::kGetNeighbors, PK::kProject, + PK::kPassThrough, PK::kDedup, PK::kStart, + PK::kProject, PK::kProject, PK::kGetNeighbors, PK::kStart, }; EXPECT_TRUE(checkResult(query, expected)); @@ -196,6 +215,7 @@ TEST_F(FindPathValidatorTest, RunTimePath) { " | FIND SHORTEST PATH FROM \"2\" TO $-.dst OVER like, serve UPTO 5 " "STEPS"; std::vector expected = { + PK::kProject, PK::kDataCollect, PK::kLoop, PK::kCartesianProduct, @@ -222,6 +242,7 @@ TEST_F(FindPathValidatorTest, RunTimePath) { " | FIND SHORTEST PATH FROM $-.src TO \"2\" OVER like, serve UPTO 5 " "STEPS"; std::vector expected = { + PK::kProject, PK::kDataCollect, PK::kLoop, PK::kCartesianProduct, @@ -248,6 +269,7 @@ TEST_F(FindPathValidatorTest, RunTimePath) { "GO FROM \"2\" OVER like yield like._src AS src, like._dst AS dst " " | FIND SHORTEST PATH FROM $a.src TO $-.dst OVER like UPTO 5 STEPS"; std::vector expected = { + PK::kProject, PK::kDataCollect, PK::kLoop, PK::kCartesianProduct, @@ -278,6 +300,7 @@ TEST_F(FindPathValidatorTest, RunTimePath) { " | FIND SHORTEST PATH FROM $-.src TO $-.dst OVER like, serve UPTO 5 " "STEPS"; std::vector expected = { + PK::kProject, PK::kDataCollect, PK::kLoop, PK::kCartesianProduct, @@ -304,6 +327,7 @@ TEST_F(FindPathValidatorTest, RunTimePath) { "YIELD \"1\" AS src, \"2\" AS dst" " | FIND ALL PATH FROM $-.src TO $-.dst OVER like, serve UPTO 5 STEPS"; std::vector expected = { + PK::kProject, PK::kDataCollect, PK::kLoop, PK::kProject, @@ -332,6 +356,7 @@ TEST_F(FindPathValidatorTest, PathWithFilter) { "FIND ALL PATH FROM \"1\" TO \"2\" OVER like WHERE like.likeness > 30 " "UPTO 5 STEPS"; std::vector expected = { + PK::kProject, PK::kDataCollect, PK::kLoop, PK::kProject, @@ -354,6 +379,7 @@ TEST_F(FindPathValidatorTest, PathWithFilter) { "FIND SHORTEST PATH FROM \"1\" TO \"2\" OVER like WHERE like.likeness " "> 30 UPTO 5 STEPS"; std::vector expected = { + PK::kProject, PK::kDataCollect, PK::kLoop, PK::kStart, @@ -374,6 +400,7 @@ TEST_F(FindPathValidatorTest, PathWithFilter) { "FIND SHORTEST PATH FROM \"1\" TO \"2\", \"3\" OVER like WHERE " "like.likeness > 30 UPTO 5 STEPS"; std::vector expected = { + PK::kProject, PK::kDataCollect, PK::kLoop, PK::kCartesianProduct, diff --git a/src/graph/validator/test/GetSubgraphValidatorTest.cpp b/src/graph/validator/test/GetSubgraphValidatorTest.cpp index 3b38d2a8318..51ee20792fe 100644 --- a/src/graph/validator/test/GetSubgraphValidatorTest.cpp +++ b/src/graph/validator/test/GetSubgraphValidatorTest.cpp @@ -191,7 +191,7 @@ TEST_F(GetSubgraphValidatorTest, invalidYield) { std::string query = "GET SUBGRAPH WITH PROP FROM \"Tim Duncan\" YIELD path"; auto result = checkResult(query); EXPECT_EQ(std::string(result.message()), - "SemanticError: Get Subgraph only support YIELD vertices OR edges"); + "SyntaxError: please add alias when using path. near `path'"); } { std::string query = "GET SUBGRAPH WITH PROP FROM \"Tim Duncan\" YIELD 123"; diff --git a/src/graph/validator/test/YieldValidatorTest.cpp b/src/graph/validator/test/YieldValidatorTest.cpp index 63bae62a91f..490b48a7203 100644 --- a/src/graph/validator/test/YieldValidatorTest.cpp +++ b/src/graph/validator/test/YieldValidatorTest.cpp @@ -224,7 +224,7 @@ TEST_F(YieldValidatorTest, TypeCastTest) { { std::string query = "YIELD (PATH)true"; auto result = checkResult(query); - EXPECT_EQ(std::string(result.message()), "SyntaxError: syntax error near `true'"); + EXPECT_EQ(std::string(result.message()), "SyntaxError: syntax error near `PATH'"); } { std::string query = "YIELD (NOEXIST)true"; diff --git a/src/parser/parser.yy b/src/parser/parser.yy index 8211147a531..2c434ba1aca 100644 --- a/src/parser/parser.yy +++ b/src/parser/parser.yy @@ -1397,7 +1397,7 @@ yield_column } | KW_PATH { $$ = nullptr; - throw nebula::GraphParser::syntax_error(@1, "please add alias when using path"); + throw nebula::GraphParser::syntax_error(@1, "please add alias when using path."); } | KW_PATH KW_AS name_label { $$ = new YieldColumn(PathBuildExpression::make(qctx->objPool()), *$3); diff --git a/tests/tck/features/match/Unwind.feature b/tests/tck/features/match/Unwind.feature index 5648eb25dad..718a18199ac 100644 --- a/tests/tck/features/match/Unwind.feature +++ b/tests/tck/features/match/Unwind.feature @@ -119,14 +119,14 @@ Feature: Unwind clause Scenario: unwind match with When executing query: """ - MATCH path=(x:player{name: "Tim Duncan"})-[:like*..2]->(y) - UNWIND nodes(path) as n - WITH path, size(collect(distinct n)) AS testLength - WHERE testLength == length(path) + 1 - RETURN path + MATCH p = (x:player{name: "Tim Duncan"})-[:like*..2]->(y) + UNWIND nodes(p) as n + WITH p, size(collect(distinct n)) AS testLength + WHERE testLength == length(p) + 1 + RETURN p """ Then the result should be, in any order: - | path | + | p | | <("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"})-[:like@0 {likeness: 95}]->("Tony Parker" :player{age: 36, name: "Tony Parker"})> | | <("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"})-[:like@0 {likeness: 95}]->("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})> | | <("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"})-[:like@0 {likeness: 95}]->("Tony Parker" :player{age: 36, name: "Tony Parker"})-[:like@0 {likeness: 95}]->("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})> | diff --git a/tests/tck/features/path/AllPath.IntVid.feature b/tests/tck/features/path/AllPath.IntVid.feature index f4599d5897c..c8c7f0b3656 100644 --- a/tests/tck/features/path/AllPath.IntVid.feature +++ b/tests/tck/features/path/AllPath.IntVid.feature @@ -113,11 +113,11 @@ Feature: Integer Vid All Path Scenario: Integer Vid [1] ALL Path With Limit When executing query: """ - FIND ALL PATH FROM hash("Tim Duncan") TO hash("Tony Parker"), hash("Spurs") OVER like,serve UPTO 3 STEPS - | ORDER BY $-.path | LIMIT 3 + FIND ALL PATH FROM hash("Tim Duncan") TO hash("Tony Parker"), hash("Spurs") OVER like,serve UPTO 3 STEPS YIELD path as p | + ORDER BY $-.p | LIMIT 3 """ Then the result should be, in any order, with relax comparison: - | path | + | p | | <("Tim Duncan")-[:like]->("Tony Parker")> | | <("Tim Duncan")-[:like]->("Tony Parker")-[:like]->("LaMarcus Aldridge")-[:like]->("Tony Parker")> | | <("Tim Duncan")-[:like]->("Tony Parker")-[:like]->("LaMarcus Aldridge")-[:serve]->("Spurs")> | @@ -126,11 +126,11 @@ Feature: Integer Vid All Path When executing query: """ $a = GO FROM hash("Tim Duncan") over * YIELD like._dst AS src, serve._src AS dst; - FIND ALL PATH FROM $a.src TO $a.dst OVER like UPTO 3 STEPS - | ORDER BY $-.path | LIMIT 5 + FIND ALL PATH FROM $a.src TO $a.dst OVER like UPTO 3 STEPS YIELD path as p | + ORDER BY $-.p | LIMIT 5 """ Then the result should be, in any order, with relax comparison: - | path | + | p | | <("Tony Parker")-[:like@0]->("LaMarcus Aldridge")-[:like@0]->("Tim Duncan")> | | <("Tony Parker")-[:like@0]->("LaMarcus Aldridge")-[:like@0]->("Tony Parker")-[:like@0]->("Tim Duncan")> | | <("Tony Parker")-[:like@0]->("Manu Ginobili")-[:like@0]->("Tim Duncan")> | @@ -253,3 +253,91 @@ Feature: Integer Vid All Path | <("Yao Ming" :player{age: 38, name: "Yao Ming"})-[:like@0 {likeness: 90}]->("Shaquile O'Neal" :player{age: 47, name: "Shaquile O'Neal"})-[:like@0 {likeness: 80}]->("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"})-[:teammate@0 {end_year: 2016, start_year: 2010}]->("Danny Green" :player{age: 31, name: "Danny Green"})> | | <("Yao Ming" :player{age: 38, name: "Yao Ming"})-[:like@0 {likeness: 90}]->("Tracy McGrady" :player{age: 39, name: "Tracy McGrady"})-[:serve@0 {end_year: 2000, start_year: 1997}]->("Raptors" :team{name: "Raptors"})<-[:serve@0 {end_year: 2019, start_year: 2018}]-("Danny Green" :player{age: 31, name: "Danny Green"})> | | <("Yao Ming" :player{age: 38, name: "Yao Ming"})-[:like@0 {likeness: 90}]->("Tracy McGrady" :player{age: 39, name: "Tracy McGrady"})-[:serve@0 {end_year: 2013, start_year: 2013}]->("Spurs" :team{name: "Spurs"})<-[:serve@0 {end_year: 2018, start_year: 2010}]-("Danny Green" :player{age: 31, name: "Danny Green"})> | + + Scenario: Integer Vid ALL PATH YIELD PATH + When executing query: + """ + FIND ALL PATH FROM hash("Tim Duncan") TO hash("Tony Parker") OVER like BIDIRECT UPTO 3 STEPS YIELD path as p + """ + Then the result should be, in any order, with relax comparison: + | p | + | <("Tim Duncan")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Marco Belinelli")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Dejounte Murray")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("LaMarcus Aldridge")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("LaMarcus Aldridge")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Manu Ginobili")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")-[:like]->("Manu Ginobili")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Boris Diaw")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Danny Green")<-[:like]-("Marco Belinelli")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Danny Green")-[:like]->("Marco Belinelli")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Dejounte Murray")-[:like]->("Marco Belinelli")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Manu Ginobili")<-[:like]-("Dejounte Murray")-[:like]->("Tony Parker")> | + | <("Tim Duncan")-[:like]->("Manu Ginobili")<-[:like]-("Dejounte Murray")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Danny Green")<-[:like]-("Dejounte Murray")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Marco Belinelli")<-[:like]-("Dejounte Murray")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Tony Parker")<-[:like]-("LaMarcus Aldridge")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")-[:like]->("Tony Parker")<-[:like]-("LaMarcus Aldridge")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Tony Parker")-[:like]->("LaMarcus Aldridge")-[:like]->("Tony Parker")> | + | <("Tim Duncan")-[:like]->("Tony Parker")-[:like]->("LaMarcus Aldridge")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Manu Ginobili")<-[:like]-("Tim Duncan")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")-[:like]->("Manu Ginobili")-[:like]->("Tim Duncan")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Manu Ginobili")<-[:like]-("Tim Duncan")-[:like]->("Tony Parker")> | + | <("Tim Duncan")-[:like]->("Manu Ginobili")-[:like]->("Tim Duncan")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Dejounte Murray")-[:like]->("Manu Ginobili")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Tiago Splitter")-[:like]->("Manu Ginobili")<-[:like]-("Tony Parker")> | + When executing query: + """ + FIND ALL PATH WITH PROP FROM hash("Yao Ming") TO hash("Danny Green") OVER * BIDIRECT + WHERE like.likeness is EMPTY OR like.likeness >= 80 UPTO 3 STEPS YIELD path as p | + YIELD startnode($-.p) as startnode + """ + Then the result should be, in any order, with relax comparison: + | startnode | + | ("Yao Ming" :player{age: 38, name: "Yao Ming"}) | + | ("Yao Ming" :player{age: 38, name: "Yao Ming"}) | + | ("Yao Ming" :player{age: 38, name: "Yao Ming"}) | + | ("Yao Ming" :player{age: 38, name: "Yao Ming"}) | + When executing query: + """ + FIND ALL PATH WITH PROP FROM hash("Yao Ming") TO hash("Danny Green") OVER * BIDIRECT + WHERE like.likeness is EMPTY OR like.likeness >= 80 UPTO 3 STEPS YIELD path as p | + YIELD endnode($-.p) as endnode + """ + Then the result should be, in any order, with relax comparison: + | endnode | + | ("Danny Green" :player{age: 31, name: "Danny Green"}) | + | ("Danny Green" :player{age: 31, name: "Danny Green"}) | + | ("Danny Green" :player{age: 31, name: "Danny Green"}) | + | ("Danny Green" :player{age: 31, name: "Danny Green"}) | + When executing query: + """ + FIND ALL PATH WITH PROP FROM hash("Tim Duncan") TO hash("Tony Parker") OVER like UPTO 3 STEPS YIELD path as p | + YIELD length($-.p) as length + """ + Then the result should be, in any order, with relax comparison: + | length | + | 1 | + | 3 | + | 3 | + When executing query: + """ + FIND ALL PATH WITH PROP FROM hash("Tim Duncan") TO hash("Tony Parker") OVER like UPTO 3 STEPS YIELD path as p | + YIELD relationships($-.p) as relationships + """ + Then the result should be, in any order, with relax comparison: + | relationships | + | [[:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}]] | + | [[:like "Tim Duncan"->"Manu Ginobili" @0 {likeness: 95}], [:like "Manu Ginobili"->"Tim Duncan" @0 {likeness: 90}], [:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}]] | + | [[:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}], [:like "Tony Parker"->"LaMarcus Aldridge" @0 {likeness: 90}], [:like "LaMarcus Aldridge"->"Tony Parker" @0 {likeness: 75}]] | + When executing query: + """ + FIND ALL PATH WITH PROP FROM hash("Tim Duncan") TO hash("Tony Parker") OVER like UPTO 3 STEPS YIELD path as p | + YIELD nodes($-.p) as nodes + """ + Then the result should be, in any order, with relax comparison: + | nodes | + | [("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"}), ("Tony Parker" :player{age: 36, name: "Tony Parker"})] | + | [("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"}), ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"}), ("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"}), ("Tony Parker" :player{age: 36, name: "Tony Parker"})] | + | [("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"}), ("Tony Parker" :player{age: 36, name: "Tony Parker"}), ("LaMarcus Aldridge" :player{age: 33, name: "LaMarcus Aldridge"}), ("Tony Parker" :player{age: 36, name: "Tony Parker"})] | diff --git a/tests/tck/features/path/AllPath.feature b/tests/tck/features/path/AllPath.feature index 99cb1e697dd..dcca1801935 100644 --- a/tests/tck/features/path/AllPath.feature +++ b/tests/tck/features/path/AllPath.feature @@ -81,8 +81,8 @@ Feature: All Path Scenario: [1] ALL Path Run Time Input When executing query: """ - GO FROM "Tim Duncan" over * YIELD like._dst AS src, serve._src AS dst - | FIND ALL PATH FROM $-.src TO $-.dst OVER like UPTO 3 STEPS + GO FROM "Tim Duncan" over * YIELD like._dst AS src, serve._src AS dst | + FIND ALL PATH FROM $-.src TO $-.dst OVER like UPTO 3 STEPS """ Then the result should be, in any order, with relax comparison: | path | @@ -113,11 +113,11 @@ Feature: All Path Scenario: [1] ALL Path With Limit When executing query: """ - FIND ALL PATH FROM "Tim Duncan" TO "Tony Parker","Spurs" OVER like,serve UPTO 3 STEPS - | ORDER BY $-.path | LIMIT 3 + FIND ALL PATH FROM "Tim Duncan" TO "Tony Parker","Spurs" OVER like,serve UPTO 3 STEPS YIELD path as p | + ORDER BY $-.p | LIMIT 3 """ Then the result should be, in any order, with relax comparison: - | path | + | p | | <("Tim Duncan")-[:like]->("Manu Ginobili")-[:serve]->("Spurs")> | | <("Tim Duncan")-[:like]->("Manu Ginobili")-[:like]->("Tim Duncan")-[:serve]->("Spurs")> | | <("Tim Duncan")-[:like]->("Manu Ginobili")-[:like]->("Tim Duncan")-[:like]->("Tony Parker")> | @@ -126,11 +126,11 @@ Feature: All Path When executing query: """ $a = GO FROM "Tim Duncan" over * YIELD like._dst AS src, serve._src AS dst; - FIND ALL PATH FROM $a.src TO $a.dst OVER like UPTO 3 STEPS - | ORDER BY $-.path | LIMIT 5 + FIND ALL PATH FROM $a.src TO $a.dst OVER like UPTO 3 STEPS YIELD path as p | + ORDER BY $-.p | LIMIT 5 """ Then the result should be, in any order, with relax comparison: - | path | + | p | | <("Manu Ginobili")-[:like]->("Tim Duncan")> | | <("Manu Ginobili")-[:like]->("Tim Duncan")-[:like]->("Tony Parker")-[:like]->("Tim Duncan")> | | <("Tony Parker")-[:like]->("LaMarcus Aldridge")-[:like]->("Tim Duncan")> | @@ -253,3 +253,91 @@ Feature: All Path | <("Yao Ming" :player{age: 38, name: "Yao Ming"})-[:like@0 {likeness: 90}]->("Shaquile O'Neal" :player{age: 47, name: "Shaquile O'Neal"})-[:like@0 {likeness: 80}]->("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"})-[:teammate@0 {end_year: 2016, start_year: 2010}]->("Danny Green" :player{age: 31, name: "Danny Green"})> | | <("Yao Ming" :player{age: 38, name: "Yao Ming"})-[:like@0 {likeness: 90}]->("Tracy McGrady" :player{age: 39, name: "Tracy McGrady"})-[:serve@0 {end_year: 2000, start_year: 1997}]->("Raptors" :team{name: "Raptors"})<-[:serve@0 {end_year: 2019, start_year: 2018}]-("Danny Green" :player{age: 31, name: "Danny Green"})> | | <("Yao Ming" :player{age: 38, name: "Yao Ming"})-[:like@0 {likeness: 90}]->("Tracy McGrady" :player{age: 39, name: "Tracy McGrady"})-[:serve@0 {end_year: 2013, start_year: 2013}]->("Spurs" :team{name: "Spurs"})<-[:serve@0 {end_year: 2018, start_year: 2010}]-("Danny Green" :player{age: 31, name: "Danny Green"})> | + + Scenario: ALL PATH YIELD PATH + When executing query: + """ + FIND ALL PATH FROM "Tim Duncan" TO "Tony Parker" OVER like BIDIRECT UPTO 3 STEPS YIELD path as p + """ + Then the result should be, in any order, with relax comparison: + | p | + | <("Tim Duncan")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Marco Belinelli")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Dejounte Murray")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("LaMarcus Aldridge")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("LaMarcus Aldridge")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Manu Ginobili")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")-[:like]->("Manu Ginobili")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Boris Diaw")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Danny Green")<-[:like]-("Marco Belinelli")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Danny Green")-[:like]->("Marco Belinelli")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Dejounte Murray")-[:like]->("Marco Belinelli")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Manu Ginobili")<-[:like]-("Dejounte Murray")-[:like]->("Tony Parker")> | + | <("Tim Duncan")-[:like]->("Manu Ginobili")<-[:like]-("Dejounte Murray")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Danny Green")<-[:like]-("Dejounte Murray")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Marco Belinelli")<-[:like]-("Dejounte Murray")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Tony Parker")<-[:like]-("LaMarcus Aldridge")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")-[:like]->("Tony Parker")<-[:like]-("LaMarcus Aldridge")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Tony Parker")-[:like]->("LaMarcus Aldridge")-[:like]->("Tony Parker")> | + | <("Tim Duncan")-[:like]->("Tony Parker")-[:like]->("LaMarcus Aldridge")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Manu Ginobili")<-[:like]-("Tim Duncan")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")-[:like]->("Manu Ginobili")-[:like]->("Tim Duncan")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Manu Ginobili")<-[:like]-("Tim Duncan")-[:like]->("Tony Parker")> | + | <("Tim Duncan")-[:like]->("Manu Ginobili")-[:like]->("Tim Duncan")-[:like]->("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Dejounte Murray")-[:like]->("Manu Ginobili")<-[:like]-("Tony Parker")> | + | <("Tim Duncan")<-[:like]-("Tiago Splitter")-[:like]->("Manu Ginobili")<-[:like]-("Tony Parker")> | + When executing query: + """ + FIND ALL PATH WITH PROP FROM "Yao Ming" TO "Danny Green" OVER * BIDIRECT + WHERE like.likeness is EMPTY OR like.likeness >= 80 UPTO 3 STEPS YIELD path as p | + YIELD startnode($-.p) as startnode + """ + Then the result should be, in any order, with relax comparison: + | startnode | + | ("Yao Ming" :player{age: 38, name: "Yao Ming"}) | + | ("Yao Ming" :player{age: 38, name: "Yao Ming"}) | + | ("Yao Ming" :player{age: 38, name: "Yao Ming"}) | + | ("Yao Ming" :player{age: 38, name: "Yao Ming"}) | + When executing query: + """ + FIND ALL PATH WITH PROP FROM "Yao Ming" TO "Danny Green" OVER * BIDIRECT + WHERE like.likeness is EMPTY OR like.likeness >= 80 UPTO 3 STEPS YIELD path as p | + YIELD endnode($-.p) as endnode + """ + Then the result should be, in any order, with relax comparison: + | endnode | + | ("Danny Green" :player{age: 31, name: "Danny Green"}) | + | ("Danny Green" :player{age: 31, name: "Danny Green"}) | + | ("Danny Green" :player{age: 31, name: "Danny Green"}) | + | ("Danny Green" :player{age: 31, name: "Danny Green"}) | + When executing query: + """ + FIND ALL PATH WITH PROP FROM "Tim Duncan" TO "Tony Parker" OVER like UPTO 3 STEPS YIELD path as p | + YIELD length($-.p) as length + """ + Then the result should be, in any order, with relax comparison: + | length | + | 1 | + | 3 | + | 3 | + When executing query: + """ + FIND ALL PATH WITH PROP FROM "Tim Duncan" TO "Tony Parker" OVER like UPTO 3 STEPS YIELD path as p | + YIELD relationships($-.p) as relationships + """ + Then the result should be, in any order, with relax comparison: + | relationships | + | [[:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}]] | + | [[:like "Tim Duncan"->"Manu Ginobili" @0 {likeness: 95}], [:like "Manu Ginobili"->"Tim Duncan" @0 {likeness: 90}], [:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}]] | + | [[:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}], [:like "Tony Parker"->"LaMarcus Aldridge" @0 {likeness: 90}], [:like "LaMarcus Aldridge"->"Tony Parker" @0 {likeness: 75}]] | + When executing query: + """ + FIND ALL PATH WITH PROP FROM "Tim Duncan" TO "Tony Parker" OVER like UPTO 3 STEPS YIELD path as p | + YIELD nodes($-.p) as nodes + """ + Then the result should be, in any order, with relax comparison: + | nodes | + | [("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"}), ("Tony Parker" :player{age: 36, name: "Tony Parker"})] | + | [("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"}), ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"}), ("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"}), ("Tony Parker" :player{age: 36, name: "Tony Parker"})] | + | [("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"}), ("Tony Parker" :player{age: 36, name: "Tony Parker"}), ("LaMarcus Aldridge" :player{age: 33, name: "LaMarcus Aldridge"}), ("Tony Parker" :player{age: 36, name: "Tony Parker"})] | diff --git a/tests/tck/features/path/NoLoop.IntVid.feature b/tests/tck/features/path/NoLoop.IntVid.feature index d42ecba0625..04c560ff3bc 100644 --- a/tests/tck/features/path/NoLoop.IntVid.feature +++ b/tests/tck/features/path/NoLoop.IntVid.feature @@ -80,11 +80,11 @@ Feature: Integer Vid NoLoop Path Scenario: Integer Vid [1] NOLOOP Path With Limit When executing query: """ - FIND NOLOOP PATH FROM hash("Tim Duncan") TO hash("Tony Parker"), hash("Spurs") OVER like,serve UPTO 3 STEPS - | ORDER BY $-.path | LIMIT 3 + FIND NOLOOP PATH FROM hash("Tim Duncan") TO hash("Tony Parker"), hash("Spurs") OVER like,serve UPTO 3 STEPS YIELD path as p | + ORDER BY $-.p | LIMIT 3 """ Then the result should be, in any order, with relax comparison: - | path | + | p | | <("Tim Duncan")-[:like]->("Tony Parker")> | | < ("Tim Duncan")-[:like]->("Tony Parker")-[:like]->("Manu Ginobili")-[:serve]->("Spurs")> | | <("Tim Duncan")-[:like]->("Tony Parker")-[:like]->("LaMarcus Aldridge")-[:serve]->("Spurs")> | @@ -93,11 +93,11 @@ Feature: Integer Vid NoLoop Path When executing query: """ $a = GO FROM hash("Tim Duncan") over * YIELD like._dst AS src, serve._src AS dst; - FIND NOLOOP PATH FROM $a.src TO $a.dst OVER like UPTO 3 STEPS - | ORDER BY $-.path | LIMIT 5 + FIND NOLOOP PATH FROM $a.src TO $a.dst OVER like UPTO 3 STEPS YIELD path as p | + ORDER BY $-.p | LIMIT 5 """ Then the result should be, in any order, with relax comparison: - | path | + | p | | <("Manu Ginobili")-[:like]->("Tim Duncan")> | | <("Tony Parker")-[:like]->("LaMarcus Aldridge")-[:like]->("Tim Duncan")> | | <("Tony Parker")-[:like]->("Manu Ginobili")-[:like]->("Tim Duncan")> | @@ -197,9 +197,49 @@ Feature: Integer Vid NoLoop Path When executing query: """ $a = GO FROM hash("Tim Duncan") over * YIELD like._dst AS src, serve._src AS dst; - FIND NOLOOP PATH WITH PROP FROM $a.src TO $a.dst OVER like WHERE like.likeness > 90 UPTO 3 STEPS - | ORDER BY $-.path | LIMIT 5 + FIND NOLOOP PATH WITH PROP FROM $a.src TO $a.dst OVER like WHERE like.likeness > 90 UPTO 3 STEPS YIELD path as p | + ORDER BY $-.p | LIMIT 5 """ Then the result should be, in any order, with relax comparison: - | path | + | p | | <("Tony Parker" :player{age: 36, name: "Tony Parker"})-[:like@0 {likeness: 95}]->("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"})> | + + Scenario: Integer Vid NOLOOP Path YIELD PATH + When executing query: + """ + FIND NOLOOP PATH WITH PROP FROM hash("Tim Duncan") TO hash("Tony Parker") OVER like UPTO 3 STEPS YIELD path as p + """ + Then the result should be, in any order, with relax comparison: + | p | + | <("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"})-[:like@0 {likeness: 95}]->("Tony Parker" :player{age: 36, name: "Tony Parker"})> | + When executing query: + """ + FIND NOLOOP PATH WITH PROP FROM hash("Tim Duncan") TO hash("Tony Parker"), hash("LaMarcus Aldridge") OVER like UPTO 3 STEPS YIELD path as p | + YIELD startnode($-.p) as startnode + """ + Then the result should be, in any order, with relax comparison: + | startnode | + | ("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"}) | + | ("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"}) | + When executing query: + """ + $a = GO FROM hash("Tim Duncan") over * YIELD like._dst AS src, serve._src AS dst; + FIND NOLOOP PATH FROM $a.src TO $a.dst OVER like UPTO 3 STEPS YIELD path as p | + YIELD nodes($-.p) as nodes + """ + Then the result should be, in any order, with relax comparison: + | nodes | + | [("Manu Ginobili"), ("Tim Duncan")] | + | [("Tony Parker"), ("Tim Duncan")] | + | [("Tony Parker"), ("Manu Ginobili"), ("Tim Duncan")] | + | [("Tony Parker"), ("LaMarcus Aldridge"), ("Tim Duncan")] | + When executing query: + """ + FIND NOLOOP PATH FROM hash("Tim Duncan") TO hash("Tony Parker") OVER like REVERSELY UPTO 3 STEPS YIELD path as p | + YIELD relationships($-.p) as relationships + """ + Then the result should be, in any order, with relax comparison: + | relationships | + | [[:like "Tony Parker"->"Tim Duncan" @0 {}]] | + | [[:like "LaMarcus Aldridge"->"Tim Duncan" @0 {}], [:like "Tony Parker"->"LaMarcus Aldridge" @0 {}]] | + | [[:like "Manu Ginobili"->"Tim Duncan" @0 {}], [:like "Tony Parker"->"Manu Ginobili" @0 {}]] | diff --git a/tests/tck/features/path/NoLoop.feature b/tests/tck/features/path/NoLoop.feature index 472e48dbac8..fbdce3db5c7 100644 --- a/tests/tck/features/path/NoLoop.feature +++ b/tests/tck/features/path/NoLoop.feature @@ -80,11 +80,11 @@ Feature: NoLoop Path Scenario: [1] NOLOOP Path With Limit When executing query: """ - FIND NOLOOP PATH FROM "Tim Duncan" TO "Tony Parker","Spurs" OVER like,serve UPTO 3 STEPS - | ORDER BY $-.path | LIMIT 3 + FIND NOLOOP PATH FROM "Tim Duncan" TO "Tony Parker","Spurs" OVER like,serve UPTO 3 STEPS YIELD path as p | + ORDER BY $-.p | LIMIT 3 """ Then the result should be, in any order, with relax comparison: - | path | + | p | | <("Tim Duncan")-[:like]->("Manu Ginobili")-[:serve]->("Spurs")> | | <("Tim Duncan")-[:serve]->("Spurs")> | | <("Tim Duncan")-[:like]->("Tony Parker")> | @@ -93,11 +93,11 @@ Feature: NoLoop Path When executing query: """ $a = GO FROM "Tim Duncan" over * YIELD like._dst AS src, serve._src AS dst; - FIND NOLOOP PATH FROM $a.src TO $a.dst OVER like UPTO 3 STEPS - | ORDER BY $-.path | LIMIT 5 + FIND NOLOOP PATH FROM $a.src TO $a.dst OVER like UPTO 3 STEPS YIELD path as p | + ORDER BY $-.p | LIMIT 5 """ Then the result should be, in any order, with relax comparison: - | path | + | p | | <("Manu Ginobili")-[:like]->("Tim Duncan")> | | <("Tony Parker")-[:like]->("LaMarcus Aldridge")-[:like]->("Tim Duncan")> | | <("Tony Parker")-[:like]->("Manu Ginobili")-[:like]->("Tim Duncan")> | @@ -197,9 +197,49 @@ Feature: NoLoop Path When executing query: """ $a = GO FROM "Tim Duncan" over * YIELD like._dst AS src, serve._src AS dst; - FIND NOLOOP PATH WITH PROP FROM $a.src TO $a.dst OVER like WHERE like.likeness > 90 UPTO 3 STEPS - | ORDER BY $-.path | LIMIT 5 + FIND NOLOOP PATH WITH PROP FROM $a.src TO $a.dst OVER like WHERE like.likeness > 90 UPTO 3 STEPS YIELD path as p | + ORDER BY $-.p | LIMIT 5 """ Then the result should be, in any order, with relax comparison: - | path | + | p | | <("Tony Parker" :player{age: 36, name: "Tony Parker"})-[:like@0 {likeness: 95}]->("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"})> | + + Scenario: NOLOOP Path YIELD PATH + When executing query: + """ + FIND NOLOOP PATH WITH PROP FROM "Tim Duncan" TO "Tony Parker" OVER like UPTO 3 STEPS YIELD path as p + """ + Then the result should be, in any order, with relax comparison: + | p | + | <("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"})-[:like@0 {likeness: 95}]->("Tony Parker" :player{age: 36, name: "Tony Parker"})> | + When executing query: + """ + FIND NOLOOP PATH WITH PROP FROM "Tim Duncan" TO "Tony Parker","LaMarcus Aldridge" OVER like UPTO 3 STEPS YIELD path as p | + YIELD startnode($-.p) as startnode + """ + Then the result should be, in any order, with relax comparison: + | startnode | + | ("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"}) | + | ("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"}) | + When executing query: + """ + $a = GO FROM "Tim Duncan" over * YIELD like._dst AS src, serve._src AS dst; + FIND NOLOOP PATH FROM $a.src TO $a.dst OVER like UPTO 3 STEPS YIELD path as p | + YIELD nodes($-.p) as nodes + """ + Then the result should be, in any order, with relax comparison: + | nodes | + | [("Manu Ginobili"), ("Tim Duncan")] | + | [("Tony Parker"), ("Tim Duncan")] | + | [("Tony Parker"), ("Manu Ginobili"), ("Tim Duncan")] | + | [("Tony Parker"), ("LaMarcus Aldridge"), ("Tim Duncan")] | + When executing query: + """ + FIND NOLOOP PATH FROM "Tim Duncan" TO "Tony Parker" OVER like REVERSELY UPTO 3 STEPS YIELD path as p | + YIELD relationships($-.p) as relationships + """ + Then the result should be, in any order, with relax comparison: + | relationships | + | [[:like "Tony Parker"->"Tim Duncan" @0 {}]] | + | [[:like "LaMarcus Aldridge"->"Tim Duncan" @0 {}], [:like "Tony Parker"->"LaMarcus Aldridge" @0 {}]] | + | [[:like "Manu Ginobili"->"Tim Duncan" @0 {}], [:like "Tony Parker"->"Manu Ginobili" @0 {}]] | diff --git a/tests/tck/features/path/ShortestPath.IntVid.feature b/tests/tck/features/path/ShortestPath.IntVid.feature index 6fe16052f59..1ff4e35cb24 100644 --- a/tests/tck/features/path/ShortestPath.IntVid.feature +++ b/tests/tck/features/path/ShortestPath.IntVid.feature @@ -317,42 +317,42 @@ Feature: Integer Vid Shortest Path Scenario: Integer Vid [1] Shortest Path With Limit When executing query: """ - FIND SHORTEST PATH FROM hash("Tim Duncan") TO hash("Nobody"), hash("Spur") OVER like,serve UPTO 3 STEPS | ORDER BY $-.path | LIMIT 3 + FIND SHORTEST PATH FROM hash("Tim Duncan") TO hash("Nobody"), hash("Spur") OVER like,serve UPTO 3 STEPS YIELD path as p | ORDER BY $-.p | LIMIT 3 """ Then the result should be, in any order, with relax comparison: - | path | + | p | Scenario: Integer Vid [2] Shortest Path With Limit When executing query: """ - FIND SHORTEST PATH FROM hash("Shaquile O\'Neal"), hash("Nobody") TO hash("Manu Ginobili"), hash("Spurs"), hash("Lakers") OVER * UPTO 5 STEPS - | ORDER BY $-.path | LIMIT 2 + FIND SHORTEST PATH FROM hash("Shaquile O\'Neal"), hash("Nobody") TO hash("Manu Ginobili"), hash("Spurs"), hash("Lakers") OVER * UPTO 5 STEPS YIELD path as p | + ORDER BY $-.p | LIMIT 2 """ Then the result should be, in any order, with relax comparison: - | path | + | p | | <("Shaquile O'Neal")-[:serve]->("Lakers")> | | <("Shaquile O'Neal")-[:like]->("Tim Duncan")-[:like]->("Manu Ginobili")> | Scenario: Integer Vid [3] Shortest Path With Limit When executing query: """ - GO FROM hash("Tim Duncan") over * YIELD like._dst AS src, serve._src AS dst - | FIND SHORTEST PATH FROM $-.src TO $-.dst OVER like UPTO 5 STEPS - | ORDER BY $-.path | LIMIT 1 + GO FROM hash("Tim Duncan") over * YIELD like._dst AS src, serve._src AS dst | + FIND SHORTEST PATH FROM $-.src TO $-.dst OVER like UPTO 5 STEPS YIELD path as p | + ORDER BY $-.p | LIMIT 1 """ Then the result should be, in any order, with relax comparison: - | path | + | p | | <("Tony Parker")-[:like@0]->("Tim Duncan")> | Scenario: Integer Vid [4] Shortest Path With Limit When executing query: """ - GO FROM hash("Tim Duncan") over * YIELD like._dst AS src, serve._src AS dst - | FIND SHORTEST PATH FROM $-.src TO $-.dst OVER like UPTO 5 STEPS - | ORDER BY $-.path | LIMIT 10 + GO FROM hash("Tim Duncan") over * YIELD like._dst AS src, serve._src AS dst | + FIND SHORTEST PATH FROM $-.src TO $-.dst OVER like UPTO 5 STEPS YIELD path as p | + ORDER BY $-.p | LIMIT 10 """ Then the result should be, in any order, with relax comparison: - | path | + | p | | <("Manu Ginobili")-[:like]->("Tim Duncan")> | | <("Tony Parker")-[:like]->("Tim Duncan")> | @@ -513,3 +513,52 @@ Feature: Integer Vid Shortest Path | <("Tony Parker" :player{age: 36, name: "Tony Parker"})<-[:teammate@0 {end_year: 2016, start_year: 2002}]-("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})> | | <("Tony Parker" :player{age: 36, name: "Tony Parker"})-[:like@0 {likeness: 95}]->("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})> | | <("Tony Parker" :player{age: 36, name: "Tony Parker"})-[:teammate@0 {end_year: 2018, start_year: 2002}]->("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})> | + + Scenario: Integer Vid Shortest Path YIELD path + When executing query: + """ + FIND SHORTEST PATH FROM hash("Shaquile O\'Neal"), hash("Nobody") TO hash("Manu Ginobili"), hash("Spurs"), hash("Lakers") OVER * UPTO 5 STEPS YIELD path as p + """ + Then the result should be, in any order, with relax comparison: + | p | + | <("Shaquile O'Neal")-[:like]->("Tim Duncan")-[:serve]->("Spurs")> | + | <("Shaquile O'Neal")-[:serve]->("Lakers")> | + | <("Shaquile O'Neal")-[:like]->("Tim Duncan")-[:like]->("Manu Ginobili")> | + | <("Shaquile O'Neal")-[:like]->("Tim Duncan")-[:teammate]->("Manu Ginobili")> | + When executing query: + """ + FIND SHORTEST PATH FROM hash("Shaquile O\'Neal"), hash("Nobody") TO hash("Manu Ginobili"), hash("Spurs"), hash("Lakers") OVER * UPTO 5 STEPS YIELD path as p | + YIELD length($-.p) as length + """ + Then the result should be, in any order, with relax comparison: + | length | + | 2 | + | 1 | + | 2 | + | 2 | + When executing query: + """ + FIND SHORTEST PATH WITH PROP FROM hash("Tony Parker"), hash("Yao Ming") TO hash("Manu Ginobili"), hash("Spurs"), hash("Lakers") OVER * BIDIRECT WHERE teammate.start_year is not EMPTY OR like.likeness > 90 UPTO 3 STEPS YIELD path as p | + YIELD nodes($-.p) as nodes + """ + Then the result should be, in any order, with relax comparison: + | nodes | + | [("Tony Parker" :player{age: 36, name: "Tony Parker"}), ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})] | + | [("Tony Parker" :player{age: 36, name: "Tony Parker"}), ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})] | + | [("Tony Parker" :player{age: 36, name: "Tony Parker"}), ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})] | + When executing query: + """ + FIND SHORTEST PATH WITH PROP FROM hash("Tony Parker"), hash("Yao Ming") TO hash("Manu Ginobili"), hash("Spurs"), hash("Lakers") OVER * BIDIRECT WHERE teammate.start_year is not EMPTY OR like.likeness > 90 UPTO 3 STEPS YIELD path as p | + YIELD distinct nodes($-.p) as nodes + """ + Then the result should be, in any order, with relax comparison: + | nodes | + | [("Tony Parker" :player{age: 36, name: "Tony Parker"}), ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})] | + When executing query: + """ + FIND SHORTEST PATH FROM hash("Tiago Splitter") TO hash("Tim Duncan") OVER * UPTO 1 STEPS YIELD path as p | + YIELD relationships($-.p) as relationships + """ + Then the result should be, in any order, with relax comparison: + | relationships | + | [[:like "Tiago Splitter"->"Tim Duncan" @0 {}]] | diff --git a/tests/tck/features/path/ShortestPath.feature b/tests/tck/features/path/ShortestPath.feature index 1a534f64b8d..01373bc80ad 100644 --- a/tests/tck/features/path/ShortestPath.feature +++ b/tests/tck/features/path/ShortestPath.feature @@ -317,42 +317,42 @@ Feature: Shortest Path Scenario: [1] Shortest Path With Limit When executing query: """ - FIND SHORTEST PATH FROM "Tim Duncan" TO "Nobody","Spur" OVER like,serve UPTO 3 STEPS | ORDER BY $-.path | LIMIT 3 + FIND SHORTEST PATH FROM "Tim Duncan" TO "Nobody","Spur" OVER like,serve UPTO 3 STEPS YIELD path as p | ORDER BY $-.p | LIMIT 3 """ Then the result should be, in any order, with relax comparison: - | path | + | p | Scenario: [2] Shortest Path With Limit When executing query: """ - FIND SHORTEST PATH FROM "Shaquile O\'Neal", "Nobody" TO "Manu Ginobili", "Spurs", "Lakers" OVER * UPTO 5 STEPS - | ORDER BY $-.path | LIMIT 2 + FIND SHORTEST PATH FROM "Shaquile O\'Neal", "Nobody" TO "Manu Ginobili", "Spurs", "Lakers" OVER * UPTO 5 STEPS YIELD path as p | + ORDER BY $-.p | LIMIT 2 """ Then the result should be, in any order, with relax comparison: - | path | + | p | | <("Shaquile O'Neal")-[:serve]->("Lakers")> | | <("Shaquile O'Neal")-[:like]->("Tim Duncan")-[:like]->("Manu Ginobili")> | Scenario: [3] Shortest Path With Limit When executing query: """ - GO FROM "Tim Duncan" over * YIELD like._dst AS src, serve._src AS dst - | FIND SHORTEST PATH FROM $-.src TO $-.dst OVER like UPTO 5 STEPS - | ORDER BY $-.path | LIMIT 1 + GO FROM "Tim Duncan" over * YIELD like._dst AS src, serve._src AS dst | + FIND SHORTEST PATH FROM $-.src TO $-.dst OVER like UPTO 5 STEPS YIELD path as p | + ORDER BY $-.p | LIMIT 1 """ Then the result should be, in any order, with relax comparison: - | path | + | p | | <("Manu Ginobili")-[:like]->("Tim Duncan")> | Scenario: [4] Shortest Path With Limit When executing query: """ - GO FROM "Tim Duncan" over * YIELD like._dst AS src, serve._src AS dst - | FIND SHORTEST PATH FROM $-.src TO $-.dst OVER like UPTO 5 STEPS - | ORDER BY $-.path | LIMIT 10 + GO FROM "Tim Duncan" over * YIELD like._dst AS src, serve._src AS dst | + FIND SHORTEST PATH FROM $-.src TO $-.dst OVER like UPTO 5 STEPS YIELD path as p | + ORDER BY $-.p | LIMIT 10 """ Then the result should be, in any order, with relax comparison: - | path | + | p | | <("Manu Ginobili")-[:like]->("Tim Duncan")> | | <("Tony Parker")-[:like]->("Tim Duncan")> | @@ -513,3 +513,52 @@ Feature: Shortest Path | <("Tony Parker" :player{age: 36, name: "Tony Parker"})<-[:teammate@0 {end_year: 2016, start_year: 2002}]-("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})> | | <("Tony Parker" :player{age: 36, name: "Tony Parker"})-[:like@0 {likeness: 95}]->("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})> | | <("Tony Parker" :player{age: 36, name: "Tony Parker"})-[:teammate@0 {end_year: 2018, start_year: 2002}]->("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})> | + + Scenario: Shortest Path YIELD path + When executing query: + """ + FIND SHORTEST PATH FROM "Shaquile O\'Neal", "Nobody" TO "Manu Ginobili", "Spurs", "Lakers" OVER * UPTO 5 STEPS YIELD path as p + """ + Then the result should be, in any order, with relax comparison: + | p | + | <("Shaquile O'Neal")-[:like]->("Tim Duncan")-[:serve]->("Spurs")> | + | <("Shaquile O'Neal")-[:serve]->("Lakers")> | + | <("Shaquile O'Neal")-[:like]->("Tim Duncan")-[:like]->("Manu Ginobili")> | + | <("Shaquile O'Neal")-[:like]->("Tim Duncan")-[:teammate]->("Manu Ginobili")> | + When executing query: + """ + FIND SHORTEST PATH FROM "Shaquile O\'Neal", "Nobody" TO "Manu Ginobili", "Spurs", "Lakers" OVER * UPTO 5 STEPS YIELD path as p | + YIELD length($-.p) as length + """ + Then the result should be, in any order, with relax comparison: + | length | + | 2 | + | 1 | + | 2 | + | 2 | + When executing query: + """ + FIND SHORTEST PATH WITH PROP FROM "Tony Parker", "Yao Ming" TO "Manu Ginobili", "Spurs", "Lakers" OVER * BIDIRECT WHERE teammate.start_year is not EMPTY OR like.likeness > 90 UPTO 3 STEPS YIELD path as p | + YIELD nodes($-.p) as nodes + """ + Then the result should be, in any order, with relax comparison: + | nodes | + | [("Tony Parker" :player{age: 36, name: "Tony Parker"}), ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})] | + | [("Tony Parker" :player{age: 36, name: "Tony Parker"}), ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})] | + | [("Tony Parker" :player{age: 36, name: "Tony Parker"}), ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})] | + When executing query: + """ + FIND SHORTEST PATH WITH PROP FROM "Tony Parker", "Yao Ming" TO "Manu Ginobili", "Spurs", "Lakers" OVER * BIDIRECT WHERE teammate.start_year is not EMPTY OR like.likeness > 90 UPTO 3 STEPS YIELD path as p | + YIELD distinct nodes($-.p) as nodes + """ + Then the result should be, in any order, with relax comparison: + | nodes | + | [("Tony Parker" :player{age: 36, name: "Tony Parker"}), ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})] | + When executing query: + """ + FIND SHORTEST PATH FROM "Tiago Splitter" TO "Tim Duncan" OVER * UPTO 1 STEPS YIELD path as p | + YIELD relationships($-.p) as relationships + """ + Then the result should be, in any order, with relax comparison: + | relationships | + | [[:like "Tiago Splitter"->"Tim Duncan" @0 {}]] |