Skip to content

Commit

Permalink
refix
Browse files Browse the repository at this point in the history
  • Loading branch information
xtcyclist committed Oct 21, 2022
1 parent 4e73163 commit 0a3f263
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/graph/planner/match/MatchPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ Status MatchPlanner::connectMatchPlan(SubPlan& queryPlan, MatchClauseContext* ma
}
queryPlan =
SegmentsConnector::leftJoin(matchCtx->qctx, queryPlan, matchPlan, intersectedAliases);
matchCtx->isOptional = false;
} else {
queryPlan =
SegmentsConnector::innerJoin(matchCtx->qctx, queryPlan, matchPlan, intersectedAliases);
Expand All @@ -124,18 +123,31 @@ Status MatchPlanner::connectMatchPlan(SubPlan& queryPlan, MatchClauseContext* ma
Status MatchPlanner::genQueryPartPlan(QueryContext* qctx,
SubPlan& queryPlan,
const QueryPart& queryPart) {
// generate plan for matchs
for (auto& match : queryPart.matchs) {
NG_RETURN_IF_ERROR(connectMatchPlan(queryPlan, match.get()));
if (queryPart.matchs.size() == 1 && queryPart.matchs[0]->isOptional) {
NG_RETURN_IF_ERROR(connectMatchPlan(queryPlan, queryPart.matchs[0].get()));
// connect match filter
if ((match->where != nullptr && !match->isOptional) ||
(match->isOptional && queryPart.matchs.size())) {
match->where->inputColNames = queryPlan.root->colNames();
auto wherePlanStatus = std::make_unique<WhereClausePlanner>()->transform(match->where.get());
if (queryPart.matchs[0]->where != nullptr) {
queryPart.matchs[0]->where->inputColNames = queryPlan.root->colNames();
auto wherePlanStatus =
std::make_unique<WhereClausePlanner>()->transform(queryPart.matchs[0]->where.get());
NG_RETURN_IF_ERROR(wherePlanStatus);
auto wherePlan = std::move(wherePlanStatus).value();
queryPlan = SegmentsConnector::addInput(wherePlan, queryPlan, true);
}
} else {
// generate plan for matchs
for (auto& match : queryPart.matchs) {
NG_RETURN_IF_ERROR(connectMatchPlan(queryPlan, match.get()));
// connect match filter
if (match->where != nullptr && !match->isOptional) {
match->where->inputColNames = queryPlan.root->colNames();
auto wherePlanStatus =
std::make_unique<WhereClausePlanner>()->transform(match->where.get());
NG_RETURN_IF_ERROR(wherePlanStatus);
auto wherePlan = std::move(wherePlanStatus).value();
queryPlan = SegmentsConnector::addInput(wherePlan, queryPlan, true);
}
}
}

if (queryPlan.root != nullptr) {
Expand Down

0 comments on commit 0a3f263

Please sign in to comment.