Skip to content

Commit

Permalink
deleted keyword LOOKUP|UPDATE and replace MULTIUPDATE with UPDATE
Browse files Browse the repository at this point in the history
  • Loading branch information
JackChuengQAQ committed Oct 12, 2024
1 parent afcca74 commit f50b9c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 75 deletions.
82 changes: 8 additions & 74 deletions src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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;
}
;

Expand Down
1 change: 0 additions & 1 deletion src/parser/scanner.lex
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down

0 comments on commit f50b9c7

Please sign in to comment.