Skip to content

Commit

Permalink
Insert vertex only (#3335)
Browse files Browse the repository at this point in the history
* add insert vertex only parser

add insert vertex only validator

fix grammar

adjust insert vertex parser

* add test

* format

* merge master

* modify parser

* add fetch test

* format

* fix fetch vertex without tag error

Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>
  • Loading branch information
cangfengzhs and Sophie-Xie authored Dec 27, 2021
1 parent 19f2bb7 commit e6fd4a9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/graph/planner/ngql/FetchVerticesPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace graph {
std::unique_ptr<FetchVerticesPlanner::VertexProps> FetchVerticesPlanner::buildVertexProps(
const ExpressionProps::TagIDPropsMap& propsMap) {
if (propsMap.empty()) {
return nullptr;
return std::make_unique<FetchVerticesPlanner::VertexProps>();
}
auto vertexProps = std::make_unique<VertexProps>(propsMap.size());
auto fun = [](auto& tag) {
Expand Down
3 changes: 3 additions & 0 deletions src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -2916,6 +2916,9 @@ insert_vertex_sentence
: KW_INSERT KW_VERTEX opt_if_not_exists opt_ignore_existed_index vertex_tag_list KW_VALUES vertex_row_list {
$$ = new InsertVerticesSentence($5, $7, $3, $4);
}
| KW_INSERT KW_VERTEX opt_if_not_exists opt_ignore_existed_index KW_VALUES vertex_row_list {
$$ = new InsertVerticesSentence(new VertexTagList(), $6, $3, $4);
}
;

vertex_tag_list
Expand Down
40 changes: 40 additions & 0 deletions tests/tck/features/insert/insertVertexOnly.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (c) 2021 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.
Feature: insert vertex without tag

Background: Background name
Given an empty graph
And create a space with following options:
| partition_num | 9 |
| replica_factor | 1 |
| vid_type | int64 |

Scenario: insert vertex only
Given having executed:
"""
CREATE EDGE e();
"""
And wait 6 seconds
When executing query:
"""
INSERT VERTEX VALUES 1:(),2:(),3:();
INSERT EDGE e() VALUES 1->2:(),2->3:();
"""
Then the execution should be successful
When executing query:
"""
GO 2 STEP FROM 1 OVER e yield e._dst AS dst;
"""
Then the result should be, in any order:
| dst |
| 3 |
When executing query:
"""
FETCH PROP ON * 1,2 yield vertex AS v;
"""
Then the result should be, in any order, with relax comparison:
| v |
| (1) |
| (2) |
Then drop the used space

0 comments on commit e6fd4a9

Please sign in to comment.