From 12cd539b2a0afe66654a523e154729cbc7668283 Mon Sep 17 00:00:00 2001 From: "hs.zhang" <22708345+cangfengzhs@users.noreply.github.com> Date: Mon, 15 Nov 2021 18:48:09 +0800 Subject: [PATCH 1/2] support delete vertex without edge --- 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 | 127 +++++++++++++++ tests/tck/features/geo/GeoBase.feature | 2 +- .../mutate/InsertWithTimeType.feature | 2 +- 12 files changed, 273 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 9048dab224f..230916cea95 100644 --- a/src/graph/validator/MutateValidator.cpp +++ b/src/graph/validator/MutateValidator.cpp @@ -306,15 +306,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(); } @@ -347,68 +349,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(); @@ -417,7 +422,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 cb8fd8a371a..f78900fb134 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 7b5259a7eaf..7a893a58cef 100644 --- a/src/parser/parser.yy +++ b/src/parser/parser.yy @@ -366,7 +366,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 @@ -2885,11 +2885,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 8a93efe6af7..da0afdbf08c 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 89f4c6e7753..950131fa733 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..157c02b3cca --- /dev/null +++ b/tests/tck/features/delete/DeleteVertexWithoutEdge.feature @@ -0,0 +1,127 @@ +# 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 0e0a33335bd..f721d424b4e 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 From 643381fe619332fd13d405a589e7714bf08dc9a4 Mon Sep 17 00:00:00 2001 From: "hs.zhang" <22708345+cangfengzhs@users.noreply.github.com> Date: Mon, 15 Nov 2021 19:09:10 +0800 Subject: [PATCH 2/2] fmt feature --- .../features/delete/DeleteVertexWithoutEdge.feature | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/tck/features/delete/DeleteVertexWithoutEdge.feature b/tests/tck/features/delete/DeleteVertexWithoutEdge.feature index 157c02b3cca..8fce80e1ede 100644 --- a/tests/tck/features/delete/DeleteVertexWithoutEdge.feature +++ b/tests/tck/features/delete/DeleteVertexWithoutEdge.feature @@ -2,13 +2,15 @@ # # 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 + + Scenario: delete vertex with edge Given having executed: """ CREATE TAG t(id int); @@ -64,6 +66,7 @@ Feature: delete vertex without edge Then the result should be, in any order: | dst | id | Then drop the used space + Scenario: delete vertex without edge Given having executed: """ @@ -82,9 +85,9 @@ Feature: delete vertex without edge 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 | + | a | id | + | 2 | 1 | + | 3 | 1 | When executing query: """ DELETE VERTEX 1;