From 5a283c6caab01d162d2b6342b86c106ff64b0bbe Mon Sep 17 00:00:00 2001 From: Sophie <84560950+Sophie-Xie@users.noreply.github.com> Date: Fri, 28 Apr 2023 17:22:35 +0800 Subject: [PATCH] fix limit (#5531) (#5532) Co-authored-by: jimingquan --- src/graph/executor/algo/AllPathsExecutor.cpp | 3 +++ tests/tck/features/path/AllPath.feature | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/graph/executor/algo/AllPathsExecutor.cpp b/src/graph/executor/algo/AllPathsExecutor.cpp index 51d794dd5e5..ebbabdfef3f 100644 --- a/src/graph/executor/algo/AllPathsExecutor.cpp +++ b/src/graph/executor/algo/AllPathsExecutor.cpp @@ -342,6 +342,9 @@ folly::Future AllPathsExecutor::buildPathMultiJobs() { if (!paths.empty()) { time::Duration convertPathTime; + if (paths.size() > limit_) { + paths.resize(limit_); + } for (auto& path : paths) { result_.rows.emplace_back(convertNPath2Row(path.first, path.second)); } diff --git a/tests/tck/features/path/AllPath.feature b/tests/tck/features/path/AllPath.feature index 91afd8c9342..3d2f8f329e5 100644 --- a/tests/tck/features/path/AllPath.feature +++ b/tests/tck/features/path/AllPath.feature @@ -244,6 +244,14 @@ Feature: All Path | <("Tony Parker")-[:like]->("LaMarcus Aldridge")-[:like]->("Tim Duncan")> | | <("Tony Parker")-[:like]->("LaMarcus Aldridge")-[:like]->("Tony Parker")-[:like]->("Tim Duncan")> | | <("Tony Parker")-[:like]->("Manu Ginobili")-[:like]->("Tim Duncan")> | + When executing query: + """ + FIND ALL PATH FROM "Tim Duncan" TO "Tony Parker","Spurs" OVER like,serve UPTO 10 STEPS YIELD path as p + | LIMIT 3 | YIELD count(*) AS cnt + """ + Then the result should be, in any order, with relax comparison: + | cnt | + | 3 | Scenario: [1] ALL PATH REVERSELY When executing query: