Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable edgelist join #5268

Merged
merged 8 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/graph/context/ast/CypherAstContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ struct Path final {
// Flag for pattern predicate
bool isPred{false};
bool isAntiPred{false};
// if false do not generate path struct
bool genPath{true};

enum PathType : int8_t { kDefault, kAllShortest, kSingleShortest };
PathType pathType{PathType::kDefault};
Expand Down
2 changes: 1 addition & 1 deletion src/graph/planner/match/MatchSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void MatchSolver::buildProjectColumns(QueryContext* qctx, const Path& path, SubP
DCHECK(!nodeInfos.empty());
addNode(nodeInfos.back());

if (!path.anonymous) {
if (path.genPath) {
DCHECK(!path.alias.empty());
columns->addColumn(new YieldColumn(DCHECK_NOTNULL(path.pathBuild), path.alias));
colNames.emplace_back(path.alias);
Expand Down
35 changes: 20 additions & 15 deletions src/graph/validator/MatchValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ Status MatchValidator::validatePath(const MatchPath *path, MatchClauseContext &m
buildEdgeInfo(path, matchClauseCtx.paths.back().edgeInfos, matchClauseCtx.aliasesGenerated));
NG_RETURN_IF_ERROR(
buildPathExpr(path, matchClauseCtx.paths.back(), matchClauseCtx.aliasesGenerated));
if (path->alias() == nullptr) {
auto &genPath = matchClauseCtx.paths.back().genPath;
genPath = false;
}
return Status::OK();
}

Expand Down Expand Up @@ -170,10 +174,7 @@ Status MatchValidator::buildPathExpr(const MatchPath *path,
}

auto *pathAlias = path->alias();
if (pathAlias == nullptr) {
return Status::OK();
}
if (!aliasesGenerated.emplace(*pathAlias, AliasType::kPath).second) {
if (pathAlias != nullptr && !aliasesGenerated.emplace(*pathAlias, AliasType::kPath).second) {
return Status::SemanticError("`%s': Redefined alias", pathAlias->c_str());
}
auto *pool = qctx_->objPool();
Expand All @@ -184,8 +185,8 @@ Status MatchValidator::buildPathExpr(const MatchPath *path,
}
pathBuild->add(InputPropertyExpression::make(pool, nodeInfos.back().alias));
pathInfo.pathBuild = std::move(pathBuild);
pathInfo.anonymous = false;
pathInfo.alias = *pathAlias;
pathInfo.anonymous = pathAlias == nullptr;
pathInfo.alias = pathAlias == nullptr ? path->toString() : *pathAlias;
return Status::OK();
}

Expand Down Expand Up @@ -1105,7 +1106,6 @@ Status MatchValidator::validateMatchPathExpr(
// Build path alias
auto matchPathPtr = matchPathExprImpl->matchPathPtr();
auto pathAlias = matchPathPtr->toString();
matchPathPtr->setAlias(new std::string(pathAlias));
if (matchPathExprImpl->genList() == nullptr) {
// Don't done in expression visitor
Expression *genList = InputPropertyExpression::make(pool, pathAlias);
Expand Down Expand Up @@ -1192,7 +1192,6 @@ Status MatchValidator::validatePathInWhere(
NG_RETURN_IF_ERROR(checkMatchPathExpr(pred, availableAliases));
// Build path alias
auto pathAlias = pred->toString();
pred->setAlias(new std::string(pathAlias));
paths.emplace_back();
NG_RETURN_IF_ERROR(validatePath(pred, paths.back()));
NG_RETURN_IF_ERROR(buildRollUpPathInfo(pred, paths.back()));
Expand All @@ -1216,7 +1215,6 @@ Status MatchValidator::validatePathInWhere(
// Build path alias
auto &matchPath = matchPathExprImpl->matchPath();
auto pathAlias = matchPath.toString();
matchPath.setAlias(new std::string(pathAlias));
if (matchPathExprImpl->genList() == nullptr) {
// Don't done in expression visitor
Expression *genList = InputPropertyExpression::make(pool, pathAlias);
Expand Down Expand Up @@ -1289,19 +1287,26 @@ Status MatchValidator::validatePathInWhere(
}

/*static*/ Status MatchValidator::buildRollUpPathInfo(const MatchPath *path, Path &pathInfo) {
DCHECK(!DCHECK_NOTNULL(path->alias())->empty());
for (const auto &node : path->nodes()) {
// The inner variable of expression will be replaced by anno variable
if (!node->alias().empty() && node->alias()[0] != '_') {
pathInfo.compareVariables.emplace_back(node->alias());
const auto &nodeAlias = node->alias();
if (!nodeAlias.empty() && !AnonVarGenerator::isAnnoVar(nodeAlias)) {
pathInfo.compareVariables.emplace_back(nodeAlias);
}
}
for (const auto &edge : path->edges()) {
if (edge->alias()[0] != '_') {
pathInfo.compareVariables.emplace_back(edge->alias());
const auto &edgeAlias = edge->alias();
if (!edgeAlias.empty() && !AnonVarGenerator::isAnnoVar(edgeAlias)) {
if (edge->range()) {
return Status::SemanticError(
"Variable '%s` 's type is edge list. not support used in multiple patterns "
"simultaneously.",
edgeAlias.c_str());
}
pathInfo.compareVariables.emplace_back(edgeAlias);
}
}
pathInfo.collectVariable = *path->alias();
pathInfo.collectVariable = path->toString();
pathInfo.rollUpApply = true;
return Status::OK();
}
Expand Down
Loading