From 630023310da1d33538cd01959c4351a8a5f8a071 Mon Sep 17 00:00:00 2001 From: sworduo Date: Tue, 7 Dec 2021 15:29:42 +0800 Subject: [PATCH 1/2] checkTypeBeforeDropIndex (#3413) Co-authored-by: Shylock Hg <33566796+Shylock-Hg@users.noreply.github.com> Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com> --- .../index/DropEdgeIndexProcessor.cpp | 21 +++++++++++++++++++ .../index/DropTagIndexProcessor.cpp | 21 +++++++++++++++++++ tests/tck/features/index/TagEdgeIndex.feature | 12 +++++++++++ 3 files changed, 54 insertions(+) diff --git a/src/meta/processors/index/DropEdgeIndexProcessor.cpp b/src/meta/processors/index/DropEdgeIndexProcessor.cpp index fdbb57ce803..02f8aa9d661 100644 --- a/src/meta/processors/index/DropEdgeIndexProcessor.cpp +++ b/src/meta/processors/index/DropEdgeIndexProcessor.cpp @@ -39,6 +39,27 @@ void DropEdgeIndexProcessor::process(const cpp2::DropEdgeIndexReq& req) { keys.emplace_back(MetaKeyUtils::indexIndexKey(spaceID, indexName)); keys.emplace_back(MetaKeyUtils::indexKey(spaceID, edgeIndexID)); + auto indexItemRet = doGet(keys.back()); + if (!nebula::ok(indexItemRet)) { + auto retCode = nebula::error(indexItemRet); + if (retCode == nebula::cpp2::ErrorCode::E_KEY_NOT_FOUND) { + retCode = nebula::cpp2::ErrorCode::E_INDEX_NOT_FOUND; + } + LOG(ERROR) << "Drop Edge Index Failed: SpaceID " << spaceID << " Index Name: " << indexName + << " error: " << apache::thrift::util::enumNameSafe(retCode); + handleErrorCode(retCode); + onFinished(); + return; + } + + auto item = MetaKeyUtils::parseIndex(nebula::value(indexItemRet)); + if (item.get_schema_id().getType() != nebula::cpp2::SchemaID::Type::edge_type) { + LOG(ERROR) << "Drop Edge Index Failed: Index Name " << indexName << " is not EdgeIndex"; + resp_.set_code(nebula::cpp2::ErrorCode::E_INDEX_NOT_FOUND); + onFinished(); + return; + } + LOG(INFO) << "Drop Edge Index " << indexName; resp_.set_id(to(edgeIndexID, EntryType::INDEX)); doSyncMultiRemoveAndUpdate(std::move(keys)); diff --git a/src/meta/processors/index/DropTagIndexProcessor.cpp b/src/meta/processors/index/DropTagIndexProcessor.cpp index 4c392277645..b079a69aa71 100644 --- a/src/meta/processors/index/DropTagIndexProcessor.cpp +++ b/src/meta/processors/index/DropTagIndexProcessor.cpp @@ -38,6 +38,27 @@ void DropTagIndexProcessor::process(const cpp2::DropTagIndexReq& req) { keys.emplace_back(MetaKeyUtils::indexIndexKey(spaceID, indexName)); keys.emplace_back(MetaKeyUtils::indexKey(spaceID, tagIndexID)); + auto indexItemRet = doGet(keys.back()); + if (!nebula::ok(indexItemRet)) { + auto retCode = nebula::error(indexItemRet); + if (retCode == nebula::cpp2::ErrorCode::E_KEY_NOT_FOUND) { + retCode = nebula::cpp2::ErrorCode::E_INDEX_NOT_FOUND; + } + LOG(ERROR) << "Drop Tag Index Failed: SpaceID " << spaceID << " Index Name: " << indexName + << " error: " << apache::thrift::util::enumNameSafe(retCode); + handleErrorCode(retCode); + onFinished(); + return; + } + + auto item = MetaKeyUtils::parseIndex(nebula::value(indexItemRet)); + if (item.get_schema_id().getType() != nebula::cpp2::SchemaID::Type::tag_id) { + LOG(ERROR) << "Drop Tag Index Failed: Index Name " << indexName << " is not TagIndex"; + resp_.set_code(nebula::cpp2::ErrorCode::E_INDEX_NOT_FOUND); + onFinished(); + return; + } + LOG(INFO) << "Drop Tag Index " << indexName; resp_.set_id(to(tagIndexID, EntryType::INDEX)); doSyncMultiRemoveAndUpdate(std::move(keys)); diff --git a/tests/tck/features/index/TagEdgeIndex.feature b/tests/tck/features/index/TagEdgeIndex.feature index 2d958badd44..40a12fbbd59 100644 --- a/tests/tck/features/index/TagEdgeIndex.feature +++ b/tests/tck/features/index/TagEdgeIndex.feature @@ -162,6 +162,12 @@ Feature: tag and edge index tests from pytest Then the result should be, in any order: | Tag Index Name | Create Tag Index | | 'multi_tag_index' | 'CREATE TAG INDEX `multi_tag_index` ON `tag_1` (\n `col2`,\n `col3`\n)' | + # Check if check tag/edge type before drop index + When executing query: + """ + DROP EDGE INDEX multi_tag_index + """ + Then an ExecutionError should be raised at runtime. When executing query: """ DROP TAG INDEX multi_tag_index @@ -405,6 +411,12 @@ Feature: tag and edge index tests from pytest Then the result should be, in any order: | Edge Index Name | Create Edge Index | | 'multi_edge_index' | 'CREATE EDGE INDEX `multi_edge_index` ON `edge_1` (\n `col2`,\n `col3`\n)' | + # Check if check tag/edge type before drop index + When executing query: + """ + DROP TAG INDEX multi_edge_index + """ + Then an ExecutionError should be raised at runtime. # Check if show create edge index works well When executing query: """ From d6f83f3cdb0a69e9991c14448bda70d35c2e0042 Mon Sep 17 00:00:00 2001 From: "hs.zhang" <22708345+cangfengzhs@users.noreply.github.com> Date: Tue, 7 Dec 2021 18:40:55 +0800 Subject: [PATCH 2/2] Support delete vertex without edge (#3316) * support delete vertex without edge * fmt feature Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com> --- src/graph/validator/MutateValidator.cpp | 146 +++++++++--------- src/graph/validator/MutateValidator.h | 1 + .../validator/test/MutateValidatorTest.cpp | 26 +++- src/parser/MutateSentences.h | 12 +- src/parser/parser.yy | 19 ++- tests/bench/delete.py | 2 +- tests/query/bugs/fixed_delete_vertex_1996.py | 2 +- .../delete/DeleteVertex.IntVid.feature | 20 +-- .../tck/features/delete/DeleteVertex.feature | 18 +-- .../delete/DeleteVertexWithoutEdge.feature | 130 ++++++++++++++++ tests/tck/features/geo/GeoBase.feature | 2 +- .../mutate/InsertWithTimeType.feature | 2 +- 12 files changed, 276 insertions(+), 104 deletions(-) create mode 100644 tests/tck/features/delete/DeleteVertexWithoutEdge.feature diff --git a/src/graph/validator/MutateValidator.cpp b/src/graph/validator/MutateValidator.cpp index 9fbb5500a85..bc4d2aad968 100644 --- a/src/graph/validator/MutateValidator.cpp +++ b/src/graph/validator/MutateValidator.cpp @@ -307,15 +307,17 @@ Status DeleteVerticesValidator::validateImpl() { vertices_.emplace_back(std::move(idStatus).value()); } } - - auto ret = qctx_->schemaMng()->getAllEdge(spaceId_); - NG_RETURN_IF_ERROR(ret); - edgeNames_ = std::move(ret).value(); - for (auto &name : edgeNames_) { - auto edgeStatus = qctx_->schemaMng()->toEdgeType(spaceId_, name); - NG_RETURN_IF_ERROR(edgeStatus); - auto edgeType = edgeStatus.value(); - edgeTypes_.emplace_back(edgeType); + withEdge_ = sentence->withEdge(); + if (withEdge_) { + auto ret = qctx_->schemaMng()->getAllEdge(spaceId_); + NG_RETURN_IF_ERROR(ret); + edgeNames_ = std::move(ret).value(); + for (auto &name : edgeNames_) { + auto edgeStatus = qctx_->schemaMng()->toEdgeType(spaceId_, name); + NG_RETURN_IF_ERROR(edgeStatus); + auto edgeType = edgeStatus.value(); + edgeTypes_.emplace_back(edgeType); + } } return Status::OK(); } @@ -348,68 +350,71 @@ Status DeleteVerticesValidator::toPlan() { auto *dedupVid = Dedup::make(qctx_, nullptr); dedupVid->setInputVar(vidVar); + DeleteVertices *dvNode = nullptr; + if (withEdge_) { + std::vector edgeProps; + // make edgeRefs and edgeProp + auto index = 0u; + DCHECK(edgeTypes_.size() == edgeNames_.size()); + auto *pool = qctx_->objPool(); + for (auto &name : edgeNames_) { + auto *edgeKeyRef = new EdgeKeyRef(EdgeSrcIdExpression::make(pool, name), + EdgeDstIdExpression::make(pool, name), + EdgeRankExpression::make(pool, name)); + edgeKeyRef->setType(EdgeTypeExpression::make(pool, name)); + qctx_->objPool()->add(edgeKeyRef); + edgeKeyRefs_.emplace_back(edgeKeyRef); + + storage::cpp2::EdgeProp edgeProp; + edgeProp.set_type(edgeTypes_[index]); + edgeProp.props_ref().value().emplace_back(kSrc); + edgeProp.props_ref().value().emplace_back(kDst); + edgeProp.props_ref().value().emplace_back(kType); + edgeProp.props_ref().value().emplace_back(kRank); + edgeProps.emplace_back(edgeProp); + + edgeProp.set_type(-edgeTypes_[index]); + edgeProps.emplace_back(std::move(edgeProp)); + index++; + } - std::vector edgeProps; - // make edgeRefs and edgeProp - auto index = 0u; - DCHECK(edgeTypes_.size() == edgeNames_.size()); - auto *pool = qctx_->objPool(); - for (auto &name : edgeNames_) { - auto *edgeKeyRef = new EdgeKeyRef(EdgeSrcIdExpression::make(pool, name), - EdgeDstIdExpression::make(pool, name), - EdgeRankExpression::make(pool, name)); - edgeKeyRef->setType(EdgeTypeExpression::make(pool, name)); - qctx_->objPool()->add(edgeKeyRef); - edgeKeyRefs_.emplace_back(edgeKeyRef); - - storage::cpp2::EdgeProp edgeProp; - edgeProp.set_type(edgeTypes_[index]); - edgeProp.props_ref().value().emplace_back(kSrc); - edgeProp.props_ref().value().emplace_back(kDst); - edgeProp.props_ref().value().emplace_back(kType); - edgeProp.props_ref().value().emplace_back(kRank); - edgeProps.emplace_back(edgeProp); - - edgeProp.set_type(-edgeTypes_[index]); - edgeProps.emplace_back(std::move(edgeProp)); - index++; - } - - auto vertexPropsPtr = std::make_unique>(); - auto edgePropsPtr = std::make_unique>(edgeProps); - auto statPropsPtr = std::make_unique>(); - auto exprPtr = std::make_unique>(); - auto *getNeighbors = GetNeighbors::make(qctx_, - dedupVid, - spaceId_, - vidRef_, - edgeTypes_, - storage::cpp2::EdgeDirection::BOTH, - nullptr, - std::move(edgePropsPtr), - std::move(statPropsPtr), - std::move(exprPtr)); - - auto *yieldColumns = pool->makeAndAdd(); - yieldColumns->addColumn(new YieldColumn(EdgeSrcIdExpression::make(pool, "*"), kSrc)); - yieldColumns->addColumn(new YieldColumn(EdgeTypeExpression::make(pool, "*"), kType)); - yieldColumns->addColumn(new YieldColumn(EdgeRankExpression::make(pool, "*"), kRank)); - yieldColumns->addColumn(new YieldColumn(EdgeDstIdExpression::make(pool, "*"), kDst)); - auto *edgeKey = Project::make(qctx_, getNeighbors, yieldColumns); - - auto *dedupEdgeKey = Dedup::make(qctx_, edgeKey); - - // create deleteEdges node - auto *edgeKeyRef = pool->makeAndAdd(InputPropertyExpression::make(pool, kSrc), - InputPropertyExpression::make(pool, kDst), - InputPropertyExpression::make(pool, kRank), - true); - edgeKeyRef->setType(InputPropertyExpression::make(pool, kType)); - auto *deNode = DeleteEdges::make(qctx_, dedupEdgeKey, spaceId_, edgeKeyRef); - - auto *dvNode = DeleteVertices::make(qctx_, deNode, spaceId_, vidRef_); - - dvNode->setInputVar(dedupVid->outputVar()); + auto vertexPropsPtr = std::make_unique>(); + auto edgePropsPtr = std::make_unique>(edgeProps); + auto statPropsPtr = std::make_unique>(); + auto exprPtr = std::make_unique>(); + auto *getNeighbors = GetNeighbors::make(qctx_, + dedupVid, + spaceId_, + vidRef_, + edgeTypes_, + storage::cpp2::EdgeDirection::BOTH, + nullptr, + std::move(edgePropsPtr), + std::move(statPropsPtr), + std::move(exprPtr)); + + auto *yieldColumns = pool->makeAndAdd(); + yieldColumns->addColumn(new YieldColumn(EdgeSrcIdExpression::make(pool, "*"), kSrc)); + yieldColumns->addColumn(new YieldColumn(EdgeTypeExpression::make(pool, "*"), kType)); + yieldColumns->addColumn(new YieldColumn(EdgeRankExpression::make(pool, "*"), kRank)); + yieldColumns->addColumn(new YieldColumn(EdgeDstIdExpression::make(pool, "*"), kDst)); + auto *edgeKey = Project::make(qctx_, getNeighbors, yieldColumns); + + auto *dedupEdgeKey = Dedup::make(qctx_, edgeKey); + + // create deleteEdges node + auto *edgeKeyRef = pool->makeAndAdd(InputPropertyExpression::make(pool, kSrc), + InputPropertyExpression::make(pool, kDst), + InputPropertyExpression::make(pool, kRank), + true); + edgeKeyRef->setType(InputPropertyExpression::make(pool, kType)); + auto *deNode = DeleteEdges::make(qctx_, dedupEdgeKey, spaceId_, edgeKeyRef); + + dvNode = DeleteVertices::make(qctx_, deNode, spaceId_, vidRef_); + dvNode->setInputVar(dedupVid->outputVar()); + } else { + dvNode = DeleteVertices::make(qctx_, dedupVid, spaceId_, vidRef_); + } root_ = dvNode; tail_ = dedupVid; return Status::OK(); @@ -418,7 +423,6 @@ Status DeleteVerticesValidator::toPlan() { Status DeleteTagsValidator::validateImpl() { auto sentence = static_cast(sentence_); spaceId_ = vctx_->whichSpace().id; - if (sentence->vertices()->isRef()) { vidRef_ = sentence->vertices()->ref(); auto type = deduceExprType(vidRef_); diff --git a/src/graph/validator/MutateValidator.h b/src/graph/validator/MutateValidator.h index 63e604652b4..a6afd084825 100644 --- a/src/graph/validator/MutateValidator.h +++ b/src/graph/validator/MutateValidator.h @@ -83,6 +83,7 @@ class DeleteVerticesValidator final : public Validator { std::vector edgeTypes_; std::vector edgeNames_; std::vector edgeKeyRefs_; + bool withEdge_{true}; }; class DeleteTagsValidator final : public Validator { diff --git a/src/graph/validator/test/MutateValidatorTest.cpp b/src/graph/validator/test/MutateValidatorTest.cpp index add40824ae8..09f7af2ba3e 100644 --- a/src/graph/validator/test/MutateValidatorTest.cpp +++ b/src/graph/validator/test/MutateValidatorTest.cpp @@ -61,7 +61,7 @@ TEST_F(MutateValidatorTest, InsertEdgeTest) { TEST_F(MutateValidatorTest, DeleteVertexTest) { // succeed { - auto cmd = "DELETE VERTEX \"A\""; + auto cmd = "DELETE VERTEX \"A\" WITH EDGE"; std::vector expected = { PK::kDeleteVertices, PK::kDeleteEdges, @@ -73,9 +73,18 @@ TEST_F(MutateValidatorTest, DeleteVertexTest) { }; ASSERT_TRUE(checkResult(cmd, expected)); } + { + auto cmd = "DELETE VERTEX \"A\""; + std::vector expected = { + PK::kDeleteVertices, + PK::kDedup, + PK::kStart, + }; + ASSERT_TRUE(checkResult(cmd, expected)); + } // pipe { - auto cmd = "GO FROM \"C\" OVER like YIELD like._dst as dst | DELETE VERTEX $-.dst"; + auto cmd = "GO FROM \"C\" OVER like YIELD like._dst as dst | DELETE VERTEX $-.dst WITH EDGE"; std::vector expected = { PK::kDeleteVertices, PK::kDeleteEdges, @@ -89,9 +98,20 @@ TEST_F(MutateValidatorTest, DeleteVertexTest) { }; ASSERT_TRUE(checkResult(cmd, expected)); } + { + auto cmd = "GO FROM \"C\" OVER like YIELD like._dst as dst | DELETE VERTEX $-.dst"; + std::vector expected = { + PK::kDeleteVertices, + PK::kDedup, + PK::kProject, + PK::kGetNeighbors, + PK::kStart, + }; + ASSERT_TRUE(checkResult(cmd, expected)); + } // pipe wrong input { - auto cmd = "GO FROM \"C\" OVER E YIELD E._dst as dst | DELETE VERTEX $-.a"; + auto cmd = "GO FROM \"C\" OVER E YIELD E._dst as dst | DELETE VERTEX $-.a WITH EDGE"; ASSERT_FALSE(checkResult(cmd)); } } diff --git a/src/parser/MutateSentences.h b/src/parser/MutateSentences.h index b15111efb98..094e3ea97bd 100644 --- a/src/parser/MutateSentences.h +++ b/src/parser/MutateSentences.h @@ -405,18 +405,22 @@ class UpdateEdgeSentence final : public UpdateBaseSentence { class DeleteVerticesSentence final : public Sentence { public: - explicit DeleteVerticesSentence(VertexIDList *vidList) - : Sentence(Kind::kDeleteVertices), vertices_(new VerticesClause(vidList)) {} + DeleteVerticesSentence(VertexIDList *vidList, bool withEdge) + : Sentence(Kind::kDeleteVertices), + vertices_(new VerticesClause(vidList)), + withEdge_(withEdge) {} - explicit DeleteVerticesSentence(Expression *ref) - : Sentence(Kind::kDeleteVertices), vertices_(new VerticesClause(ref)) {} + DeleteVerticesSentence(Expression *ref, bool withEdge) + : Sentence(Kind::kDeleteVertices), vertices_(new VerticesClause(ref)), withEdge_(withEdge) {} const VerticesClause *vertices() const { return vertices_.get(); } std::string toString() const override; + bool withEdge() const { return withEdge_; } private: std::unique_ptr vertices_; + bool withEdge_{true}; }; class DeleteTagsSentence final : public Sentence { diff --git a/src/parser/parser.yy b/src/parser/parser.yy index 0ea8ede2672..59b567ceda3 100644 --- a/src/parser/parser.yy +++ b/src/parser/parser.yy @@ -365,7 +365,7 @@ static constexpr size_t kCommentLengthLimit = 256; %type mutate_sentence %type insert_vertex_sentence insert_edge_sentence -%type delete_vertex_sentence delete_edge_sentence delete_tag_sentence +%type delete_vertex_sentence delete_edge_sentence delete_tag_sentence delete_vertex_with_edge_sentence %type update_vertex_sentence update_edge_sentence %type download_sentence ingest_sentence @@ -2971,11 +2971,24 @@ update_edge_sentence delete_vertex_sentence : KW_DELETE KW_VERTEX vid_list { - auto sentence = new DeleteVerticesSentence($3); + auto sentence = new DeleteVerticesSentence($3, false); $$ = sentence; } | KW_DELETE KW_VERTEX vid_ref_expression { - auto sentence = new DeleteVerticesSentence($3); + auto sentence = new DeleteVerticesSentence($3, false); + $$ = sentence; + } + | KW_DELETE KW_VERTEX delete_vertex_with_edge_sentence { + $$ = $3; + } + ; +delete_vertex_with_edge_sentence + : vid_list KW_WITH KW_EDGE { + auto sentence = new DeleteVerticesSentence($1, true); + $$ = sentence; + } + | vid_ref_expression KW_WITH KW_EDGE { + auto sentence = new DeleteVerticesSentence($1, true); $$ = sentence; } ; diff --git a/tests/bench/delete.py b/tests/bench/delete.py index 42e129e6dcc..54d92d77982 100644 --- a/tests/bench/delete.py +++ b/tests/bench/delete.py @@ -48,7 +48,7 @@ def delete(self, duration=0.000001): for col in row.columns: if col.getType() == ttypes.ColumnValue.ID: id = col.get_id() - resp = self.execute('DELETE VERTEX {0}'.format(id)) + resp = self.execute('DELETE VERTEX {0} WITH EDGE'.format(id)) self.check_resp_succeeded(resp) resp = self.execute('lookup on person where person.age == {0} '.format(i)) diff --git a/tests/query/bugs/fixed_delete_vertex_1996.py b/tests/query/bugs/fixed_delete_vertex_1996.py index c24af694f85..a410cd39452 100644 --- a/tests/query/bugs/fixed_delete_vertex_1996.py +++ b/tests/query/bugs/fixed_delete_vertex_1996.py @@ -27,7 +27,7 @@ def test_issue1996(self): time.sleep(self.delay) resp = self.execute('INSERT VERTEX person(name, age) VALUES 101:("Tony Parker", 36)') self.check_resp_succeeded(resp) - resp = self.execute('DELETE VERTEX 101') + resp = self.execute('DELETE VERTEX 101 WITH EDGE') self.check_resp_succeeded(resp) @classmethod diff --git a/tests/tck/features/delete/DeleteVertex.IntVid.feature b/tests/tck/features/delete/DeleteVertex.IntVid.feature index 8843ddede3c..60326b7344a 100644 --- a/tests/tck/features/delete/DeleteVertex.IntVid.feature +++ b/tests/tck/features/delete/DeleteVertex.IntVid.feature @@ -44,7 +44,7 @@ Feature: Delete int vid of vertex # delete one vertex When executing query: """ - DELETE VERTEX hash("Tony Parker"); + DELETE VERTEX hash("Tony Parker") WITH EDGE; """ Then the execution should be successful # after delete to check value by fetch @@ -89,7 +89,7 @@ Feature: Delete int vid of vertex # delete multi vertexes When executing query: """ - DELETE VERTEX hash("LeBron James"), hash("Dwyane Wade"), hash("Carmelo Anthony"); + DELETE VERTEX hash("LeBron James"), hash("Dwyane Wade"), hash("Carmelo Anthony") WITH EDGE; """ Then the execution should be successful # after delete multi vertexes to check value by go @@ -136,7 +136,7 @@ Feature: Delete int vid of vertex # delete hash id vertex When executing query: """ - DELETE VERTEX hash("Grant Hill") + DELETE VERTEX hash("Grant Hill") WITH EDGE """ Then the execution should be successful # after delete hash id vertex to check value by go @@ -165,14 +165,14 @@ Feature: Delete int vid of vertex # delete not existed vertex When executing query: """ - DELETE VERTEX hash("Non-existing Vertex") + DELETE VERTEX hash("Non-existing Vertex") WITH EDGE """ Then the execution should be successful # delete a vertex without edges When executing query: """ INSERT VERTEX player(name, age) VALUES hash("A Loner"): ("A Loner", 0); - DELETE VERTEX hash("A Loner"); + DELETE VERTEX hash("A Loner") WITH EDGE; """ Then the execution should be successful # check delete a vertex without edges @@ -185,7 +185,7 @@ Feature: Delete int vid of vertex # delete with no edge When executing query: """ - DELETE VERTEX hash("Nobody") + DELETE VERTEX hash("Nobody") WITH EDGE """ Then the execution should be successful # check delete with no edge @@ -201,7 +201,7 @@ Feature: Delete int vid of vertex # test delete with pipe wrong vid type When executing query: """ - GO FROM hash("Boris Diaw") OVER like YIELD (string)like._src as id | DELETE VERTEX $-.id + GO FROM hash("Boris Diaw") OVER like YIELD (string)like._src as id | DELETE VERTEX $-.id WITH EDGE """ Then a SemanticError should be raised at runtime: # delete with pipe, get result by go @@ -232,7 +232,7 @@ Feature: Delete int vid of vertex | "Manu Ginobili" | When executing query: """ - GO FROM hash("Boris Diaw") OVER like YIELD like._dst as id | DELETE VERTEX $-.id + GO FROM hash("Boris Diaw") OVER like YIELD like._dst as id | DELETE VERTEX $-.id WITH EDGE """ Then the execution should be successful When executing query: @@ -257,7 +257,7 @@ Feature: Delete int vid of vertex Scenario: delete with pipe failed, because of the wrong vid type When executing query: """ - USE nba_int_vid;YIELD "Tom" as id | DELETE VERTEX $-.id; + USE nba_int_vid;YIELD "Tom" as id | DELETE VERTEX $-.id WITH EDGE; """ Then a SemanticError should be raised at runtime: The vid `$-.id' should be type of `INT', but was`STRING' Then drop the used space @@ -288,7 +288,7 @@ Feature: Delete int vid of vertex | "Russell Westbrook" | When executing query: """ - $var = GO FROM hash("Russell Westbrook") OVER like YIELD like._dst as id; DELETE VERTEX $var.id + $var = GO FROM hash("Russell Westbrook") OVER like YIELD like._dst as id; DELETE VERTEX $var.id WITH EDGE """ Then the execution should be successful When executing query: diff --git a/tests/tck/features/delete/DeleteVertex.feature b/tests/tck/features/delete/DeleteVertex.feature index c5a248284fb..7da665c0403 100644 --- a/tests/tck/features/delete/DeleteVertex.feature +++ b/tests/tck/features/delete/DeleteVertex.feature @@ -44,7 +44,7 @@ Feature: Delete string vid of vertex # delete one vertex When executing query: """ - DELETE VERTEX "Tony Parker"; + DELETE VERTEX "Tony Parker" WITH EDGE; """ Then the execution should be successful # after delete to check value by fetch @@ -89,7 +89,7 @@ Feature: Delete string vid of vertex # delete multi vertexes When executing query: """ - DELETE VERTEX "LeBron James", "Dwyane Wade", "Carmelo Anthony"; + DELETE VERTEX "LeBron James", "Dwyane Wade", "Carmelo Anthony" WITH EDGE; """ Then the execution should be successful # after delete multi vertexes to check value by go @@ -136,7 +136,7 @@ Feature: Delete string vid of vertex # delete hash id vertex When executing query: """ - DELETE VERTEX "Grant Hill" + DELETE VERTEX "Grant Hill" WITH EDGE """ Then the execution should be successful # after delete hash id vertex to check value by go @@ -165,14 +165,14 @@ Feature: Delete string vid of vertex # delete not existed vertex When executing query: """ - DELETE VERTEX "Non-existing Vertex" + DELETE VERTEX "Non-existing Vertex" WITH EDGE """ Then the execution should be successful # delete a vertex without edges When executing query: """ INSERT VERTEX player(name, age) VALUES "A Loner": ("A Loner", 0); - DELETE VERTEX "A Loner"; + DELETE VERTEX "A Loner" WITH EDGE; """ Then the execution should be successful # check delete a vertex without edges @@ -185,7 +185,7 @@ Feature: Delete string vid of vertex # delete with no edge When executing query: """ - DELETE VERTEX "Nobody" + DELETE VERTEX "Nobody" WITH EDGE """ Then the execution should be successful # check delete with no edge @@ -202,7 +202,7 @@ Feature: Delete string vid of vertex # test delete with pipe wrong vid type When executing query: """ - GO FROM "Boris Diaw" OVER like YIELD like._type as id | DELETE VERTEX $-.id + GO FROM "Boris Diaw" OVER like YIELD like._type as id | DELETE VERTEX $-.id WITH EDGE """ Then a SemanticError should be raised at runtime: # delete with pipe, get result by go @@ -233,7 +233,7 @@ Feature: Delete string vid of vertex | "Manu Ginobili" | When executing query: """ - GO FROM "Boris Diaw" OVER like YIELD like._dst as id | DELETE VERTEX $-.id + GO FROM "Boris Diaw" OVER like YIELD like._dst as id | DELETE VERTEX $-.id WITH EDGE """ Then the execution should be successful When executing query: @@ -281,7 +281,7 @@ Feature: Delete string vid of vertex | "Russell Westbrook" | When executing query: """ - $var = GO FROM "Russell Westbrook" OVER like YIELD like._dst as id; DELETE VERTEX $var.id + $var = GO FROM "Russell Westbrook" OVER like YIELD like._dst as id; DELETE VERTEX $var.id WITH EDGE """ Then the execution should be successful When executing query: diff --git a/tests/tck/features/delete/DeleteVertexWithoutEdge.feature b/tests/tck/features/delete/DeleteVertexWithoutEdge.feature new file mode 100644 index 00000000000..8fce80e1ede --- /dev/null +++ b/tests/tck/features/delete/DeleteVertexWithoutEdge.feature @@ -0,0 +1,130 @@ +# Copyright (c) 2021 vesoft inc. All rights reserved. +# +# This source code is licensed under Apache 2.0 License. +Feature: delete vertex without edge + + Background: + Given an empty graph + And create a space with following options: + | partition_num | 9 | + | replica_factor | 1 | + | vid_type | int64 | + + Scenario: delete vertex with edge + Given having executed: + """ + CREATE TAG t(id int); + CREATE EDGE e(); + """ + And wait 4 seconds + When executing query: + """ + INSERT VERTEX t(id) VALUES 1:(1),2:(2),3:(3); + INSERT EDGE e() VALUES 1->2:(),1->3:(); + """ + Then the execution should be successful + When executing query: + """ + GO 1 STEP FROM 1 OVER e YIELD e._dst AS dst, $^.t.id as id; + """ + Then the result should be, in any order: + | dst | id | + | 2 | 1 | + | 3 | 1 | + When executing query: + """ + DELETE VERTEX 1 WITH EDGE; + """ + Then the execution should be successful + When executing query: + """ + FETCH PROP ON t 1 yield vertex as v; + """ + Then the result should be, in any order: + | v | + When executing query: + """ + FETCH PROP ON e 1->2 yield edge as e; + """ + Then the result should be, in any order: + | e | + When executing query: + """ + GO 1 STEP FROM 1 OVER e YIELD e._dst AS dst, $^.t.id as id + """ + Then the result should be, in any order: + | dst | id | + When executing query: + """ + INSERT VERTEX t(id) VALUES 1:(1) + """ + Then the execution should be successful + When executing query: + """ + GO 1 STEP FROM 1 OVER e YIELD e._dst AS dst, $^.t.id as id; + """ + Then the result should be, in any order: + | dst | id | + Then drop the used space + + Scenario: delete vertex without edge + Given having executed: + """ + CREATE TAG t(id int); + CREATE EDGE e(); + """ + And wait 4 seconds + When executing query: + """ + INSERT VERTEX t(id) VALUES 1:(1),2:(2),3:(2); + INSERT EDGE e() VALUES 1->2:(),1->3:(); + """ + Then the execution should be successful + When executing query: + """ + GO 1 STEP FROM 1 OVER e YIELD e._dst AS a, $^.t.id AS id; + """ + Then the result should be, in any order: + | a | id | + | 2 | 1 | + | 3 | 1 | + When executing query: + """ + DELETE VERTEX 1; + """ + Then the execution should be successful + When executing query: + """ + FETCH PROP ON t 1 yield vertex as v; + """ + Then the result should be, in any order: + | v | + When executing query: + """ + FETCH PROP ON e 1->2 yield edge as e; + """ + Then the result should be, in any order: + | e | + | [:e 1->2 @0 {}] | + When executing query: + """ + GO 1 STEP FROM 1 OVER e YIELD e._dst AS b, $^.t.id as id; + """ + Then the result should be, in any order: + | b | id | + | 2 | EMPTY | + | 3 | EMPTY | + When executing query: + """ + INSERT VERTEX t(id) VALUES 1:(1) + """ + Then the execution should be successful + When executing query: + """ + GO 1 STEP FROM 1 OVER e YIELD e._dst AS c, $^.t.id as id; + """ + Then the result should be, in any order: + | c | id | + | 2 | 1 | + | 3 | 1 | + Then drop the used space diff --git a/tests/tck/features/geo/GeoBase.feature b/tests/tck/features/geo/GeoBase.feature index 31705b7e9ca..d321432254e 100644 --- a/tests/tck/features/geo/GeoBase.feature +++ b/tests/tck/features/geo/GeoBase.feature @@ -676,7 +676,7 @@ Feature: Geo base # Delete vertex with index When executing query: """ - DELETE VERTEX "101"; + DELETE VERTEX "101" WITH EDGE; """ Then the execution should be successful When executing query: diff --git a/tests/tck/features/mutate/InsertWithTimeType.feature b/tests/tck/features/mutate/InsertWithTimeType.feature index f594de96922..8f0bbb140cb 100644 --- a/tests/tck/features/mutate/InsertWithTimeType.feature +++ b/tests/tck/features/mutate/InsertWithTimeType.feature @@ -133,7 +133,7 @@ Feature: Insert with time-dependent types | '2018-03-04' | '22:01:00.000000' | '2018-03-04T22:30:40.000000' | When executing query: """ - DELETE VERTEX "test"; + DELETE VERTEX "test" WITH EDGE; DELETE EDGE edge_date "test_src"->"test_dst"; """ Then the execution should be successful