From 46710df46b4e987adb4f983fd7a362f74c96d886 Mon Sep 17 00:00:00 2001 From: "kyle.cao" Date: Mon, 17 Apr 2023 11:08:58 +0800 Subject: [PATCH] Fix edge all predicate with rank function (#5503) Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com> --- .../rule/EmbedEdgeAllPredIntoTraverseRule.cpp | 4 ++++ .../features/match/MultiLineMultiQueryParts.feature | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/graph/optimizer/rule/EmbedEdgeAllPredIntoTraverseRule.cpp b/src/graph/optimizer/rule/EmbedEdgeAllPredIntoTraverseRule.cpp index 1a58da9c0b9..d66bd1d5d77 100644 --- a/src/graph/optimizer/rule/EmbedEdgeAllPredIntoTraverseRule.cpp +++ b/src/graph/optimizer/rule/EmbedEdgeAllPredIntoTraverseRule.cpp @@ -65,6 +65,10 @@ bool isEdgeAllPredicate(const Expression* e, return false; } auto ves = graph::ExpressionUtils::collectAll(pe->filter(), {Expression::Kind::kAttribute}); + if (ves.empty()) { + // innerVar.prop not exists + return false; + } for (const auto& ve : ves) { auto iv = static_cast(ve)->left(); diff --git a/tests/tck/features/match/MultiLineMultiQueryParts.feature b/tests/tck/features/match/MultiLineMultiQueryParts.feature index 1f0030c2831..60b1163777e 100644 --- a/tests/tck/features/match/MultiLineMultiQueryParts.feature +++ b/tests/tck/features/match/MultiLineMultiQueryParts.feature @@ -298,6 +298,17 @@ Feature: Multi Line Multi Query Parts Then the result should be, in order: | scount | lcount | | 19 | 110 | + When executing query: + """ + MATCH (m:player{name:"Tim Duncan"})-[e:like*2..3]-(n)--() + WHERE all(i in e where rank(i)==0) + WITH m,count(*) AS lcount + MATCH (m)--(n) + RETURN count(*) AS scount, lcount + """ + Then the result should be, in order: + | scount | lcount | + | 19 | 2888 | When executing query: """ MATCH (m:player{name:"Tim Duncan"})-[:like]-(n)--()