From f50b9c756cfa5f2a5a792f17c78b2678ab37db97 Mon Sep 17 00:00:00 2001 From: Jack Chueng <767407581@qq.com> Date: Sat, 12 Oct 2024 07:29:46 +0000 Subject: [PATCH] deleted keyword LOOKUP|UPDATE and replace MULTIUPDATE with UPDATE --- src/parser/parser.yy | 82 +++++------------------------------------- src/parser/scanner.lex | 1 - 2 files changed, 8 insertions(+), 75 deletions(-) diff --git a/src/parser/parser.yy b/src/parser/parser.yy index 16bba386667..58d78e3c458 100644 --- a/src/parser/parser.yy +++ b/src/parser/parser.yy @@ -184,7 +184,7 @@ using namespace nebula; %token KW_BY KW_DOWNLOAD KW_HDFS KW_UUID KW_CONFIGS KW_FORCE %token KW_GET KW_DECLARE KW_GRAPH KW_META KW_STORAGE KW_AGENT %token KW_TTL KW_TTL_DURATION KW_TTL_COL KW_DATA KW_STOP -%token KW_FETCH KW_PROP KW_UPDATE KW_MULTIUPDATE KW_UPSERT KW_WHEN +%token KW_FETCH KW_PROP KW_UPDATE KW_UPSERT KW_WHEN %token KW_ORDER KW_ASC KW_LIMIT KW_SAMPLE KW_OFFSET KW_ASCENDING KW_DESCENDING %token KW_DISTINCT KW_ALL KW_OF %token KW_BALANCE KW_LEADER KW_RESET KW_PLAN @@ -580,7 +580,6 @@ unreserved_keyword | KW_RENAME { $$ = new std::string("rename"); } | KW_CLEAR { $$ = new std::string("clear"); } | KW_ANALYZER { $$ = new std::string("analyzer"); } - | KW_MULTIUPDATE { $$ = new std::string("multiupdate"); } ; expression @@ -2176,74 +2175,9 @@ lookup_sentence ; lookup_pipe_update_sentence - : KW_LOOKUP PIPE KW_UPDATE KW_VERTEX KW_ON name_label lookup_where_clause KW_SET update_list when_clause yield_clause { - // yield_clause for lookup_sentence is only `id(vertex) as id` - ArgumentList* optArgList = ArgumentList::make(qctx->objPool()); - Expression* arg = VertexExpression::make(qctx->objPool()); - optArgList->addArgument(arg); - Expression* idExpr = FunctionCallExpression::make(qctx->objPool(), "id", optArgList); - YieldColumn* idYieldColumn = new YieldColumn(idExpr, "id"); - - auto fields = new YieldColumns(); - fields->addColumn(idYieldColumn); - auto vid_yield_clause = new YieldClause(fields, true); - - std::string* name_label_copy = new std::string(*$6); - - // look up - auto lookup_sentence = new LookupSentence($6, $7, vid_yield_clause); - - // input_ref `$-.id` - auto vid_input_ref = InputPropertyExpression::make(qctx->objPool(), "id"); - - // multiupdate - auto ref_update_sentence = new UpdateRefVertexSentence(vid_input_ref, name_label_copy, $9, $10, $11); - - $$ = new PipedSentence(lookup_sentence, ref_update_sentence); - } - | lookup_sentence PIPE update_ref_vertex_sentence { + : lookup_sentence PIPE update_ref_vertex_sentence { $$ = new PipedSentence($1, $3); } - | KW_LOOKUP PIPE KW_UPDATE KW_EDGE KW_ON name_label lookup_where_clause KW_SET update_list when_clause yield_clause { - // yield_clause for lookup_sentence is `src(edge) as src, dst(edge) as dst, rank(edge) as rank` - ArgumentList* arg_list_src = ArgumentList::make(qctx->objPool()); - Expression *arg_src = EdgeExpression::make(qctx->objPool()); - arg_list_src->addArgument(arg_src); - Expression* srcExpr = FunctionCallExpression::make(qctx->objPool(), "src", arg_list_src); - YieldColumn* srcYieldColumn = new YieldColumn(srcExpr, "src"); - - ArgumentList* arg_list_dst = ArgumentList::make(qctx->objPool()); - Expression *arg_dst = EdgeExpression::make(qctx->objPool()); - arg_list_dst->addArgument(arg_dst); - Expression* dstExpr = FunctionCallExpression::make(qctx->objPool(), "dst", arg_list_dst); - YieldColumn* dstYieldColumn = new YieldColumn(dstExpr, "dst"); - - ArgumentList* arg_list_rank = ArgumentList::make(qctx->objPool()); - Expression *arg_rank = EdgeExpression::make(qctx->objPool()); - arg_list_rank->addArgument(arg_rank); - Expression* rankExpr = FunctionCallExpression::make(qctx->objPool(), "rank", arg_list_rank); - YieldColumn* rankYieldColumn = new YieldColumn(rankExpr, "rank"); - - auto fields = new YieldColumns(); - fields->addColumn(srcYieldColumn); - fields->addColumn(dstYieldColumn); - fields->addColumn(rankYieldColumn); - auto edge_yield_clause = new YieldClause(fields, true); - - std::string* name_label_copy = new std::string(*$6); - auto lookup_sentence = new LookupSentence($6, $7, edge_yield_clause); - - // input_ref `$-.src -> $-.dst @ $-.rank` - auto src_input_ref = InputPropertyExpression::make(qctx->objPool(), "src"); - auto dst_input_ref = InputPropertyExpression::make(qctx->objPool(), "dst"); - auto rank_input_ref = InputPropertyExpression::make(qctx->objPool(), "rank"); - - auto edge_key_ref = new EdgeKeyRef(src_input_ref, dst_input_ref, rank_input_ref); - - auto update_ref_edge_sentence = new UpdateRefEdgeSentence(edge_key_ref, name_label_copy, $9, $10, $11); - - $$ = new PipedSentence(lookup_sentence, update_ref_edge_sentence); - } | lookup_sentence PIPE update_ref_edge_sentence { $$ = new PipedSentence($1, $3); } @@ -3274,14 +3208,14 @@ update_vertex_sentence // Follow the syntax of 3.0+ update_multi_vertex_sentence - : KW_MULTIUPDATE KW_VERTEX KW_ON name_label vid_list KW_SET update_list when_clause yield_clause { + : KW_UPDATE KW_VERTEX KW_ON name_label vid_list KW_SET update_list when_clause yield_clause { auto sentence = new UpdateMultiVertexSentence($5, $4, $7, $8, $9); $$ = sentence; } ; update_ref_vertex_sentence - : KW_MULTIUPDATE KW_VERTEX KW_ON name_label vid_ref_expression KW_SET update_list when_clause yield_clause { + : KW_UPDATE KW_VERTEX KW_ON name_label vid_ref_expression KW_SET update_list when_clause yield_clause { if(graph::ExpressionUtils::findAny($5,{Expression::Kind::kVar})) { throw nebula::GraphParser::syntax_error(@5, "Parameter is not supported in update clause"); } @@ -3336,19 +3270,19 @@ update_edge_sentence ; update_multi_edge_sentence - : KW_MULTIUPDATE KW_EDGE KW_ON name_label edge_keys + : KW_UPDATE KW_EDGE KW_ON name_label edge_keys KW_SET update_list when_clause yield_clause { auto sentence = new UpdateMultiEdgeSentence($5, $4, $7, $8, $9); - $$ = sentence; + $$ = sentence; } ; update_ref_edge_sentence - : KW_MULTIUPDATE KW_EDGE KW_ON name_label edge_key_ref + : KW_UPDATE KW_EDGE KW_ON name_label edge_key_ref KW_SET update_list when_clause yield_clause { auto sentence = new UpdateRefEdgeSentence($5, $4, $7, $8, $9); - $$ = sentence; + $$ = sentence; } ; diff --git a/src/parser/scanner.lex b/src/parser/scanner.lex index 583fe1e3c2f..ba4e539c895 100644 --- a/src/parser/scanner.lex +++ b/src/parser/scanner.lex @@ -110,7 +110,6 @@ LABEL_FULL_WIDTH {CN_EN_FULL_WIDTH}{CN_EN_NUM_FULL_WIDTH}* "EDGE" { return TokenType::KW_EDGE; } "EDGES" { return TokenType::KW_EDGES; } "UPDATE" { return TokenType::KW_UPDATE; } -"MULTIUPDATE" { return TokenType::KW_MULTIUPDATE; } "UPSERT" { return TokenType::KW_UPSERT; } "WHEN" { return TokenType::KW_WHEN; } "DELETE" { return TokenType::KW_DELETE; }