Skip to content

Commit

Permalink
Check variable existence and modify doc. (#1151)
Browse files Browse the repository at this point in the history
  • Loading branch information
CPWstatic authored and dutor committed Nov 19, 2019
1 parent 1ae90bb commit e4b8af7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ nebula> FETCH PROP ON player 1 YIELD player.name, player.age
nebula> FETCH PROP ON player hash(\"nebula\") YIELD player.name, player.age
-- 沿边 e1 寻找节点 1 的所有近邻,返回其姓名和年龄属性
nebula> GO FROM 1 over e1 YIELD e1._dst AS id | FETCH PROP ON player $-.id YIELD player.name, player.age
-- 与上述语句相同
-- 与上述语法相同
nebula> $var = GO FROM 1 over e1 YIELD e1._dst AS id; FETCH PROP ON player $var.id YIELD player.name, player.age
-- 获取 1,2,3 三个节点,返回姓名和年龄都不相同的记录
nebula> FETCH PROP ON player 1,2,3 YIELD DISTINCT player.name, player.age
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The `FETCH` syntax is used to get vertex/edge's properties.

## Fetch Vertex property

Use `FETCH PROP ON` to return a (list of) vertex's properties. Currently, you can get multiple vertices' properties with the same tag in one sentence.
Use `FETCH PROP ON` to return a (list of) vertex's properties. Currently, you can get multiple vertices' properties with the same tag in one sentence.

```ngql
FETCH PROP ON <tag_name> <vertex_id_list> [YIELD [DISTINCT] <return_list>]
Expand Down
13 changes: 7 additions & 6 deletions src/graph/FetchEdgesExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,17 @@ Status FetchEdgesExecutor::setupEdgeKeysFromRef() {
const InterimResult *inputs;
if (sentence_->ref()->isInputExpr()) {
inputs = inputs_.get();
if (inputs == nullptr || !inputs->hasData()) {
// we have empty imputs from pipe.
return Status::OK();
}
} else {
inputs = ectx()->variableHolder()->get(varname_);
if (inputs == nullptr || !inputs->hasData()) {
bool existing = false;
inputs = ectx()->variableHolder()->get(varname_, &existing);
if (!existing) {
return Status::Error("Variable `%s' not defined", varname_.c_str());
}
}
if (inputs == nullptr || !inputs->hasData()) {
// we have empty imputs from pipe.
return Status::OK();
}

auto ret = inputs->getVIDs(*srcid_);
if (!ret.ok()) {
Expand Down
11 changes: 6 additions & 5 deletions src/graph/FetchVerticesExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,16 @@ Status FetchVerticesExecutor::setupVidsFromRef() {
const InterimResult *inputs;
if (varname_ == nullptr) {
inputs = inputs_.get();
if (inputs == nullptr || !inputs->hasData()) {
return Status::OK();
}
} else {
inputs = ectx()->variableHolder()->get(*varname_);
if (inputs == nullptr || !inputs->hasData()) {
bool existing = false;
inputs = ectx()->variableHolder()->get(*varname_, &existing);
if (!existing) {
return Status::Error("Variable `%s' not defined", varname_->c_str());
}
}
if (inputs == nullptr || !inputs->hasData()) {
return Status::OK();
}

StatusOr<std::vector<VertexID>> result;
if (distinct_) {
Expand Down

0 comments on commit e4b8af7

Please sign in to comment.