From 9467c878d6a1544bdb349445ad008976b2902fbe Mon Sep 17 00:00:00 2001 From: Yichen Wang <18348405+Aiee@users.noreply.github.com> Date: Fri, 9 Jul 2021 10:28:29 +0800 Subject: [PATCH 1/3] [Minor] Add cases from Issue (#1217) * Fix typo and add cases * Fix type and add cases from issue --- src/optimizer/OptimizerUtils.cpp | 2 +- .../bugfix/StringFlaotAddition.feature | 69 +++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 tests/tck/features/bugfix/StringFlaotAddition.feature diff --git a/src/optimizer/OptimizerUtils.cpp b/src/optimizer/OptimizerUtils.cpp index 618166f81..748e94494 100644 --- a/src/optimizer/OptimizerUtils.cpp +++ b/src/optimizer/OptimizerUtils.cpp @@ -813,7 +813,7 @@ bool OptimizerUtils::findOptimalIndex(const Expression* condition, const std::vector>& indexItems, bool* isPrefixScan, IndexQueryContext* ictx) { - // Return directly if there is not valid index to use. + // Return directly if there is no valid index to use. if (indexItems.empty()) { return false; } diff --git a/tests/tck/features/bugfix/StringFlaotAddition.feature b/tests/tck/features/bugfix/StringFlaotAddition.feature new file mode 100644 index 000000000..b08cd18e5 --- /dev/null +++ b/tests/tck/features/bugfix/StringFlaotAddition.feature @@ -0,0 +1,69 @@ +# Copyright (c) 2021 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License, +# attached with Common Clause Condition 1.0, found in the LICENSES directory. +Feature: Test return float plus string + + Background: + Given a graph with space named "nba" + + # Fix https://github.com/vesoft-inc/nebula-graph/issues/1214 + Scenario: addition[1] + When executing query: + """ + RETURN 30.142857142857142 + "Yao Ming" + """ + Then the result should be, in any order, with relax comparison: + | (30.142857142857142+"Yao Ming") | + | "30.142857142857142Yao Ming" | + When executing query: + """ + RETURN -30.142857142857142 + "Yao Ming" + """ + Then the result should be, in any order, with relax comparison: + | (-(30.142857142857142)+"Yao Ming") | + | "-30.142857142857142Yao Ming" | + When executing query: + """ + RETURN "Yao Ming" + 30.142857142857142 + """ + Then the result should be, in any order, with relax comparison: + | ("Yao Ming"+30.142857142857142) | + | "Yao Ming30.142857142857142" | + When executing query: + """ + RETURN "Yao Ming" + -30.142857142857142 + """ + Then the result should be, in any order, with relax comparison: + | ("Yao Ming"+-(30.142857142857142)) | + | "Yao Ming-30.142857142857142" | + + Scenario: addition[2] + When executing query: + """ + RETURN 30.14 + "Yao Ming" + """ + Then the result should be, in any order, with relax comparison: + | (30.14+"Yao Ming") | + | "30.14Yao Ming" | + When executing query: + """ + RETURN -30.14 + "Yao Ming" + """ + Then the result should be, in any order, with relax comparison: + | (-(30.14)+"Yao Ming") | + | "-30.14Yao Ming" | + When executing query: + """ + RETURN "Yao Ming" + 30.14 + """ + Then the result should be, in any order, with relax comparison: + | ("Yao Ming"+30.14) | + | "Yao Ming30.14" | + When executing query: + """ + RETURN "Yao Ming" + -30.14 + """ + Then the result should be, in any order, with relax comparison: + | ("Yao Ming"+-(30.14)) | + | "Yao Ming-30.14" | From f7228db1bd41ac636c5859e87456212f31b965c3 Mon Sep 17 00:00:00 2001 From: jimingquan Date: Fri, 9 Jul 2021 21:28:54 +0800 Subject: [PATCH 2/3] fix multi-shortestPath bug --- .../algo/ProduceSemiShortestPathExecutor.cpp | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/executor/algo/ProduceSemiShortestPathExecutor.cpp b/src/executor/algo/ProduceSemiShortestPathExecutor.cpp index c2fcb5042..e54db663a 100644 --- a/src/executor/algo/ProduceSemiShortestPathExecutor.cpp +++ b/src/executor/algo/ProduceSemiShortestPathExecutor.cpp @@ -86,9 +86,7 @@ void ProduceSemiShortestPathExecutor::dstNotInHistory(const Edge& edge, auto cost = srcPath.second.cost_ + weight; std::vector newPaths = createPaths(srcPath.second.paths_, edge); - std::unordered_map temp = { - {srcPath.first, CostPaths(cost, newPaths)}}; - currentCostPathMap.emplace(dst, std::move(temp)); + currentCostPathMap[dst].emplace(srcPath.first, CostPaths(cost, std::move(newPaths))); } } else { // dst in current @@ -102,6 +100,7 @@ void ProduceSemiShortestPathExecutor::removeSamePath(std::vector& paths, auto iter = paths.begin(); while (iter != paths.end()) { if (*iter == *ptr) { + VLOG(2) << "Erese Path :" << *iter; iter = paths.erase(iter); } else { ++iter; @@ -124,9 +123,7 @@ void ProduceSemiShortestPathExecutor::dstInHistory(const Edge& edge, // (dst, startVid)'s path not in history auto newCost = srcPath.second.cost_ + weight; std::vector newPaths = createPaths(srcPath.second.paths_, edge); - std::unordered_map temp = { - {srcPath.first, CostPaths(newCost, newPaths)}}; - currentCostPathMap.emplace(dst, std::move(temp)); + currentCostPathMap[dst].emplace(srcPath.first, CostPaths(newCost, std::move(newPaths))); } else { // (dst, startVid)'s path in history, compare cost auto newCost = srcPath.second.cost_ + weight; @@ -136,9 +133,7 @@ void ProduceSemiShortestPathExecutor::dstInHistory(const Edge& edge, } else if (newCost < historyCost) { // update (dst, startVid)'s path std::vector newPaths = createPaths(srcPath.second.paths_, edge); - std::unordered_map temp = { - {srcPath.first, CostPaths(newCost, newPaths)}}; - currentCostPathMap.emplace(dst, std::move(temp)); + currentCostPathMap[dst].emplace(srcPath.first, CostPaths(newCost, std::move(newPaths))); } else { std::vector newPaths = createPaths(srcPath.second.paths_, edge); // if same path in history, remove it @@ -146,9 +141,7 @@ void ProduceSemiShortestPathExecutor::dstInHistory(const Edge& edge, if (newPaths.empty()) { continue; } - std::unordered_map temp = { - {srcPath.first, CostPaths(newCost, newPaths)}}; - currentCostPathMap.emplace(dst, std::move(temp)); + currentCostPathMap[dst].emplace(srcPath.first, CostPaths(newCost, std::move(newPaths))); } } } @@ -220,11 +213,11 @@ folly::Future ProduceSemiShortestPathExecutor::execute() { path.src = Vertex(src, {}); path.steps.emplace_back(Step(Vertex(dst, {}), edge.type, edge.name, edge.ranking, {})); if (currentCostPathMap.find(dst) != currentCostPathMap.end()) { - // same (src, dst), diffrent edge type or rank if (currentCostPathMap[dst].find(src) == currentCostPathMap[dst].end()) { CostPaths costPaths(weight, {std::move(path)}); currentCostPathMap[dst].emplace(src, std::move(costPaths)); } else { + // same (src, dst), diffrent edge type or rank auto currentCost = currentCostPathMap[dst][src].cost_; if (weight == currentCost) { currentCostPathMap[dst][src].paths_.emplace_back(std::move(path)); @@ -237,8 +230,7 @@ folly::Future ProduceSemiShortestPathExecutor::execute() { } } else { CostPaths costPaths(weight, {std::move(path)}); - std::unordered_map temp = {{src, std::move(costPaths)}}; - currentCostPathMap.emplace(dst, std::move(temp)); + currentCostPathMap[dst].emplace(src, std::move(costPaths)); } } else { if (historyCostPathMap_.find(dst) == historyCostPathMap_.end()) { @@ -272,7 +264,7 @@ folly::Future ProduceSemiShortestPathExecutor::execute() { updateHistory(dst, srcPath.first, cost, ds.rows.back().values.back()); } } - + VLOG(2) << "SemiShortPath : " << ds; return finish(ResultBuilder().value(Value(std::move(ds))).finish()); } From e529dbaef105221de17ebbf1b6969470d89158a7 Mon Sep 17 00:00:00 2001 From: jimingquan Date: Fri, 9 Jul 2021 21:54:09 +0800 Subject: [PATCH 3/3] fix format --- src/executor/algo/ProduceSemiShortestPathExecutor.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/executor/algo/ProduceSemiShortestPathExecutor.cpp b/src/executor/algo/ProduceSemiShortestPathExecutor.cpp index e54db663a..b769ea825 100644 --- a/src/executor/algo/ProduceSemiShortestPathExecutor.cpp +++ b/src/executor/algo/ProduceSemiShortestPathExecutor.cpp @@ -123,7 +123,8 @@ void ProduceSemiShortestPathExecutor::dstInHistory(const Edge& edge, // (dst, startVid)'s path not in history auto newCost = srcPath.second.cost_ + weight; std::vector newPaths = createPaths(srcPath.second.paths_, edge); - currentCostPathMap[dst].emplace(srcPath.first, CostPaths(newCost, std::move(newPaths))); + currentCostPathMap[dst].emplace(srcPath.first, + CostPaths(newCost, std::move(newPaths))); } else { // (dst, startVid)'s path in history, compare cost auto newCost = srcPath.second.cost_ + weight; @@ -133,7 +134,8 @@ void ProduceSemiShortestPathExecutor::dstInHistory(const Edge& edge, } else if (newCost < historyCost) { // update (dst, startVid)'s path std::vector newPaths = createPaths(srcPath.second.paths_, edge); - currentCostPathMap[dst].emplace(srcPath.first, CostPaths(newCost, std::move(newPaths))); + currentCostPathMap[dst].emplace(srcPath.first, + CostPaths(newCost, std::move(newPaths))); } else { std::vector newPaths = createPaths(srcPath.second.paths_, edge); // if same path in history, remove it @@ -141,7 +143,8 @@ void ProduceSemiShortestPathExecutor::dstInHistory(const Edge& edge, if (newPaths.empty()) { continue; } - currentCostPathMap[dst].emplace(srcPath.first, CostPaths(newCost, std::move(newPaths))); + currentCostPathMap[dst].emplace(srcPath.first, + CostPaths(newCost, std::move(newPaths))); } } }