Skip to content

Commit

Permalink
Fix UT
Browse files Browse the repository at this point in the history
  • Loading branch information
Aiee committed Dec 1, 2022
1 parent f2fca8d commit 444bdcb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
40 changes: 24 additions & 16 deletions src/graph/planner/match/MatchPathPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,24 +292,28 @@ Status MatchPathPlanner::leftExpandFromNode(
}
}

auto& node = nodeInfos.front();
if (!node.anonymous) {
nodeAliasesSeenInPattern.emplace(node.alias);
auto& lastNode = nodeInfos.front();

bool duppedLastAlias =
nodeAliasesSeenInPattern.find(lastNode.alias) != nodeAliasesSeenInPattern.end() &&
nodeAliasesSeenInPattern.size() > 1;

if (!lastNode.anonymous) {
nodeAliasesSeenInPattern.emplace(lastNode.alias);
}

auto appendV = AppendVertices::make(qctx, subplan.root, spaceId);
auto vertexProps = SchemaUtil::getAllVertexProp(qctx, spaceId, true);
NG_RETURN_IF_ERROR(vertexProps);
appendV->setVertexProps(std::move(vertexProps).value());
appendV->setSrc(nextTraverseStart);
appendV->setVertexFilter(genVertexFilter(node));
appendV->setVertexFilter(genVertexFilter(lastNode));
appendV->setDedup();
appendV->setTrackPrevPath(!edgeInfos.empty());
appendV->setColNames(genAppendVColNames(subplan.root->colNames(), node, !edgeInfos.empty()));
appendV->setColNames(genAppendVColNames(subplan.root->colNames(), lastNode, !edgeInfos.empty()));
subplan.root = appendV;

auto& lastNode = nodeInfos.front();
bool expandInto = nodeAliasesSeenInPattern.find(lastNode.alias) != nodeAliasesSeenInPattern.end();
if (expandInto) {
if (duppedLastAlias) {
auto* startVid = nodeId(qctx->objPool(), lastNode);
auto* endVid = nextTraverseStart;
auto* filterExpr = RelationalExpression::makeEQ(qctx->objPool(), startVid, endVid);
Expand Down Expand Up @@ -366,24 +370,28 @@ Status MatchPathPlanner::rightExpandFromNode(
}
}

auto& node = nodeInfos.back();
if (!node.anonymous) {
nodeAliasesSeenInPattern.emplace(node.alias);
auto& lastNode = nodeInfos.back();

bool duppedLastAlias =
nodeAliasesSeenInPattern.find(lastNode.alias) != nodeAliasesSeenInPattern.end() &&
nodeAliasesSeenInPattern.size() > 1;

if (!lastNode.anonymous) {
nodeAliasesSeenInPattern.emplace(lastNode.alias);
}

auto appendV = AppendVertices::make(qctx, subplan.root, spaceId);
auto vertexProps = SchemaUtil::getAllVertexProp(qctx, spaceId, true);
NG_RETURN_IF_ERROR(vertexProps);
appendV->setVertexProps(std::move(vertexProps).value());
appendV->setSrc(nextTraverseStart);
appendV->setVertexFilter(genVertexFilter(node));
appendV->setVertexFilter(genVertexFilter(lastNode));
appendV->setDedup();
appendV->setTrackPrevPath(!edgeInfos.empty());
appendV->setColNames(genAppendVColNames(subplan.root->colNames(), node, !edgeInfos.empty()));
appendV->setColNames(genAppendVColNames(subplan.root->colNames(), lastNode, !edgeInfos.empty()));
subplan.root = appendV;

auto& lastNode = nodeInfos.back();
bool expandInto = nodeAliasesSeenInPattern.find(lastNode.alias) != nodeAliasesSeenInPattern.end();
if (expandInto) {
if (duppedLastAlias) {
auto* startVid = nodeId(qctx->objPool(), lastNode);
auto* endVid = nextTraverseStart;
auto* filterExpr = RelationalExpression::makeEQ(qctx->objPool(), startVid, endVid);
Expand Down
13 changes: 13 additions & 0 deletions src/graph/validator/test/MatchValidatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,19 @@ TEST_F(MatchValidatorTest, validateAlias) {
std::string(result.message()),
"SemanticError: keywords: vertex and edge are not supported in return clause `EDGE AS b'");
}
// Duplicate alias at the end of the pattern
{
std::string query = "MATCH (v :person{name:\"Tim Duncan\"})-[e]->(v2)-[]->(v2) RETURN e";
std::vector<PlanNode::Kind> expected = {PlanNode::Kind::kProject,
PlanNode::Kind::kProject,
PlanNode::Kind::kFilter,
PlanNode::Kind::kAppendVertices,
PlanNode::Kind::kTraverse,
PlanNode::Kind::kTraverse,
PlanNode::Kind::kIndexScan,
PlanNode::Kind::kStart};
EXPECT_TRUE(checkResult(query, expected));
}
}

} // namespace graph
Expand Down

0 comments on commit 444bdcb

Please sign in to comment.