Skip to content

Commit

Permalink
Fix the dst vertex use default value when use the nonexistent tag (ve…
Browse files Browse the repository at this point in the history
  • Loading branch information
laura-ding authored May 19, 2020
1 parent 3b40d9e commit 021023a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/graph/GoExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,8 @@ bool GoExecutor::processFinalResult(RpcResponse &rpcResp, Callback cb) const {
return value(res);
};
// In reverse mode, it is used to get the src props.
getters.getDstTagProp = [&dstId,
getters.getDstTagProp = [&spaceId,
&dstId,
this] (const std::string &tag,
const std::string &prop) -> OptVariantType {
TagID tagId;
Expand All @@ -1130,7 +1131,15 @@ bool GoExecutor::processFinalResult(RpcResponse &rpcResp, Callback cb) const {
return Status::Error(
"Get tag id for `%s' failed in getters.", tag.c_str());
}
return vertexHolder_->get(dstId, tagId, prop);
auto ret = vertexHolder_->get(dstId, tagId, prop);
if (!ret.ok()) {
auto ts = ectx()->schemaManager()->getTagSchema(spaceId, tagId);
if (ts == nullptr) {
return Status::Error("No tag schema for %s", tag.c_str());
}
return RowReader::getDefaultProp(ts.get(), prop);
}
return ret.value();
};
getters.getVariableProp = [&srcId,
this] (const std::string &prop) {
Expand Down Expand Up @@ -1238,7 +1247,8 @@ OptVariantType GoExecutor::VertexHolder::getDefaultProp(TagID tid, const std::st
}
}

return Status::Error("Unknown Vertex");

return Status::Error("Unknown property: `%s'", prop.c_str());
}

SupportedType GoExecutor::VertexHolder::getDefaultPropType(TagID tid,
Expand Down
12 changes: 12 additions & 0 deletions src/graph/test/GoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2400,6 +2400,18 @@ TEST_P(GoTest, ZeroStep) {
}
}

TEST_P(GoTest, ErrorMsg) {
{
cpp2::ExecutionResponse resp;
auto *fmt = "GO FROM %ld OVER serve YIELD $$.player.name as name";
auto query = folly::stringPrintf(fmt, players_["Tim Duncan"].vid());
auto code = client_->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
std::vector<std::tuple<std::string>> expected = {""};
ASSERT_TRUE(verifyResult(resp, expected));
}
}

INSTANTIATE_TEST_CASE_P(IfPushdownFilter, GoTest, ::testing::Bool());
} // namespace graph
} // namespace nebula

0 comments on commit 021023a

Please sign in to comment.