From 3a454be28c77099a974cb7d48c01c4efbdc686ee Mon Sep 17 00:00:00 2001 From: shylock <33566796+Shylock-Hg@users.noreply.github.com> Date: Sun, 23 Oct 2022 09:04:11 +0800 Subject: [PATCH] Fix/find start error (#4771) * Fix find start error. * Fix test. Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com> --- src/graph/planner/match/ArgumentFinder.h | 4 ++++ src/graph/planner/match/LabelIndexSeek.cpp | 2 +- src/graph/planner/match/LabelIndexSeek.h | 4 ++++ src/graph/planner/match/PropIndexSeek.h | 4 ++++ src/graph/planner/match/ScanSeek.h | 4 ++++ src/graph/planner/match/StartVidFinder.h | 2 ++ src/graph/planner/match/VertexIdSeek.h | 4 ++++ tests/tck/features/bugfix/FindStartError.feature | 16 ++++++++++++++++ 8 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/tck/features/bugfix/FindStartError.feature diff --git a/src/graph/planner/match/ArgumentFinder.h b/src/graph/planner/match/ArgumentFinder.h index 1c7a31d3ba5..e344a705ba6 100644 --- a/src/graph/planner/match/ArgumentFinder.h +++ b/src/graph/planner/match/ArgumentFinder.h @@ -26,6 +26,10 @@ class ArgumentFinder final : public StartVidFinder { StatusOr transformEdge(EdgeContext* edgeCtx) override; + const char* name() const override { + return "ArgumentFinder"; + } + private: ArgumentFinder() = default; }; diff --git a/src/graph/planner/match/LabelIndexSeek.cpp b/src/graph/planner/match/LabelIndexSeek.cpp index 54b07f43628..9c95008c97d 100644 --- a/src/graph/planner/match/LabelIndexSeek.cpp +++ b/src/graph/planner/match/LabelIndexSeek.cpp @@ -91,7 +91,7 @@ StatusOr LabelIndexSeek::transformNode(NodeContext* nodeCtx) { if (filter->kind() == Expression::Kind::kLogicalOr) { auto exprs = ExpressionUtils::collectAll(filter, {Expression::Kind::kLabelTagProperty}); - bool matched = true; + bool matched = exprs.empty() ? false : true; for (auto* expr : exprs) { auto tagPropExpr = static_cast(expr); if (static_cast(tagPropExpr->label())->prop() != nodeAlias || diff --git a/src/graph/planner/match/LabelIndexSeek.h b/src/graph/planner/match/LabelIndexSeek.h index 24f6b550d23..45c797136f5 100644 --- a/src/graph/planner/match/LabelIndexSeek.h +++ b/src/graph/planner/match/LabelIndexSeek.h @@ -18,6 +18,10 @@ class LabelIndexSeek final : public StartVidFinder { return std::unique_ptr(new LabelIndexSeek()); } + const char* name() const override { + return "LabelIndexSeekFinder"; + } + private: LabelIndexSeek() = default; diff --git a/src/graph/planner/match/PropIndexSeek.h b/src/graph/planner/match/PropIndexSeek.h index 821178e1615..9a9b52c70c9 100644 --- a/src/graph/planner/match/PropIndexSeek.h +++ b/src/graph/planner/match/PropIndexSeek.h @@ -26,6 +26,10 @@ class PropIndexSeek final : public StartVidFinder { StatusOr transformEdge(EdgeContext* edgeCtx) override; + const char* name() const override { + return "PropIndexSeekFinder"; + } + private: PropIndexSeek() = default; }; diff --git a/src/graph/planner/match/ScanSeek.h b/src/graph/planner/match/ScanSeek.h index c07243d8a7f..03e522c4fa8 100644 --- a/src/graph/planner/match/ScanSeek.h +++ b/src/graph/planner/match/ScanSeek.h @@ -26,6 +26,10 @@ class ScanSeek final : public StartVidFinder { StatusOr transformEdge(EdgeContext* edgeCtx) override; + const char* name() const override { + return "ScanSeekFinder"; + } + private: ScanSeek() = default; }; diff --git a/src/graph/planner/match/StartVidFinder.h b/src/graph/planner/match/StartVidFinder.h index bc841274e71..7726ef0b646 100644 --- a/src/graph/planner/match/StartVidFinder.h +++ b/src/graph/planner/match/StartVidFinder.h @@ -61,6 +61,8 @@ class StartVidFinder { virtual StatusOr transformEdge(EdgeContext* edgeCtx) = 0; + virtual const char* name() const = 0; + protected: StartVidFinder() = default; }; diff --git a/src/graph/planner/match/VertexIdSeek.h b/src/graph/planner/match/VertexIdSeek.h index b3ea83d5f60..5b5746209c8 100644 --- a/src/graph/planner/match/VertexIdSeek.h +++ b/src/graph/planner/match/VertexIdSeek.h @@ -30,6 +30,10 @@ class VertexIdSeek final : public StartVidFinder { std::string listToAnnoVarVid(QueryContext* qctx, const List& list); + const char* name() const override { + return "VertexIdSeekFinder"; + } + private: VertexIdSeek() = default; }; diff --git a/tests/tck/features/bugfix/FindStartError.feature b/tests/tck/features/bugfix/FindStartError.feature new file mode 100644 index 00000000000..f4ad71868e1 --- /dev/null +++ b/tests/tck/features/bugfix/FindStartError.feature @@ -0,0 +1,16 @@ +# Copyright (c) 2022 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License. +Feature: Test find start error for property index seek + + Background: + Given a graph with space named "nba" + + # #4763 + Scenario: Find start of match pattern + When executing query: + """ + WITH 1 as a MATCH (v:player) WHERE a == 3 OR (a + 1) == 4 RETURN v.player.name; + """ + Then the result should be, in any order: + | v.player.name |