From d6e853c13d46553bd7a5c107b3b8de3ebf7e083e Mon Sep 17 00:00:00 2001 From: laura-ding <48548375+laura-ding@users.noreply.github.com> Date: Fri, 10 May 2019 19:13:23 +0800 Subject: [PATCH] Add AlterEdgeProcessor, GetEdgeProcessor, RemoveEdgeProcessor and UTs (#346) * add AlterEdgeProcessor, GetEdgeProcessor, RemoveEdgeProcessor * address dangleptr's comment * rebase master modify SET to CHANGE * fix UT --- src/executor/AlterTagExecutor.cpp | 16 ++++++++-------- src/executor/AlterTagExecutor.h | 2 +- src/executor/test/SchemaTest.cpp | 5 +---- src/parser/MaintainSentences.h | 2 +- src/parser/parser.yy | 4 ++-- src/parser/test/ParserTest.cpp | 2 +- 6 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/executor/AlterTagExecutor.cpp b/src/executor/AlterTagExecutor.cpp index 020bd984e49..76cf4de7aad 100644 --- a/src/executor/AlterTagExecutor.cpp +++ b/src/executor/AlterTagExecutor.cpp @@ -27,9 +27,9 @@ void AlterTagExecutor::execute() { const auto& tagOpts = sentence_->tagOptList(); auto spaceId = ectx()->rctx()->session()->space(); - std::vector tagItems; + std::vector tagItems; for (auto& tagOpt : tagOpts) { - nebula::meta::cpp2::AlterTagItem tagItem; + nebula::meta::cpp2::AlterSchemaItem tagItem; auto opType = getTagOpType(tagOpt->getOptType()); tagItem.set_op(std::move(opType)); const auto& specs = tagOpt->columnSpecs(); @@ -65,17 +65,17 @@ void AlterTagExecutor::execute() { std::move(future).via(runner).thenValue(cb).thenError(error); } -nebula::meta::cpp2::AlterTagOp +nebula::meta::cpp2::AlterSchemaOp AlterTagExecutor::getTagOpType(const AlterTagOptItem::OptionType type) { switch (type) { case AlterTagOptItem::OptionType::ADD : - return nebula::meta::cpp2::AlterTagOp::ADD; - case AlterTagOptItem::OptionType::SET : - return nebula::meta::cpp2::AlterTagOp::SET; + return nebula::meta::cpp2::AlterSchemaOp::ADD; + case AlterTagOptItem::OptionType::CHANGE : + return nebula::meta::cpp2::AlterSchemaOp::CHANGE; case AlterTagOptItem::OptionType::DROP : - return nebula::meta::cpp2::AlterTagOp::DROP; + return nebula::meta::cpp2::AlterSchemaOp::DROP; default: - return nebula::meta::cpp2::AlterTagOp::UNKNOWN; + return nebula::meta::cpp2::AlterSchemaOp::UNKNOWN; } } } // namespace graph diff --git a/src/executor/AlterTagExecutor.h b/src/executor/AlterTagExecutor.h index 9906978e16f..f7b019ca0c5 100644 --- a/src/executor/AlterTagExecutor.h +++ b/src/executor/AlterTagExecutor.h @@ -27,7 +27,7 @@ class AlterTagExecutor final : public Executor { private: AlterTagSentence *sentence_{nullptr}; - nebula::meta::cpp2::AlterTagOp + nebula::meta::cpp2::AlterSchemaOp getTagOpType(const AlterTagOptItem::OptionType type); }; diff --git a/src/executor/test/SchemaTest.cpp b/src/executor/test/SchemaTest.cpp index c2fc058b44f..083408144de 100644 --- a/src/executor/test/SchemaTest.cpp +++ b/src/executor/test/SchemaTest.cpp @@ -116,7 +116,7 @@ TEST_F(SchemaTest, metaCommunication) { cpp2::ExecutionResponse resp; std::string query = "ALTER TAG account " "ADD (col1 int TTL = 200, col2 string), " - "SET (balance string), " + "CHANGE (balance string), " "DROP (id)"; auto code = client->execute(query, resp); ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code); @@ -208,13 +208,10 @@ TEST_F(SchemaTest, metaCommunication) { }; ASSERT_TRUE(verifyResult(resp, expected)); } - /* test the same tag in diff space, but now meta server not supported, - * will add a issue(#292) to resolve it */ { cpp2::ExecutionResponse resp; std::string query = "CREATE TAG person(name string, interest string)"; auto code = client->execute(query, resp); - sleep(FLAGS_load_data_interval_second + 1); ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code); } { diff --git a/src/parser/MaintainSentences.h b/src/parser/MaintainSentences.h index 5fdf3928a90..c9dcf989028 100644 --- a/src/parser/MaintainSentences.h +++ b/src/parser/MaintainSentences.h @@ -128,7 +128,7 @@ class AlterTagOptItem final { public: enum OptionType : uint8_t { ADD = 0x01, - SET = 0x02, + CHANGE = 0x02, DROP = 0x03 }; diff --git a/src/parser/parser.yy b/src/parser/parser.yy index ab09fe863c0..c04ef5447c0 100644 --- a/src/parser/parser.yy +++ b/src/parser/parser.yy @@ -518,8 +518,8 @@ alter_tag_opt_item : KW_ADD L_PAREN column_spec_list R_PAREN { $$ = new AlterTagOptItem(AlterTagOptItem::ADD, $3); } - | KW_SET L_PAREN column_spec_list R_PAREN { - $$ = new AlterTagOptItem(AlterTagOptItem::SET, $3); + | KW_CHANGE L_PAREN column_spec_list R_PAREN { + $$ = new AlterTagOptItem(AlterTagOptItem::CHANGE, $3); } | KW_DROP L_PAREN column_spec_list R_PAREN { $$ = new AlterTagOptItem(AlterTagOptItem::DROP, $3); diff --git a/src/parser/test/ParserTest.cpp b/src/parser/test/ParserTest.cpp index 43510eeb5e8..7cf1bb34b4a 100644 --- a/src/parser/test/ParserTest.cpp +++ b/src/parser/test/ParserTest.cpp @@ -117,7 +117,7 @@ TEST(Parser, AlterTag) { { GQLParser parser; std::string query = "ALTER TAG person ADD (col1 int TTL = 200, col2 string), " - "SET (col3 int TTL = 200, col4 string), " + "CHANGE (col3 int TTL = 200, col4 string), " "DROP (col5, col6)"; auto result = parser.parse(query); ASSERT_TRUE(result.ok()) << result.status();