Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Dec 20, 2021
1 parent 381f916 commit 4ac7d4f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
14 changes: 12 additions & 2 deletions src/graph/validator/GoValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Status GoValidator::validateImpl() {
NG_RETURN_IF_ERROR(ValidateUtil::validateStep(goSentence->stepClause(), goCtx_->steps));
NG_RETURN_IF_ERROR(validateStarts(goSentence->fromClause(), goCtx_->from));
NG_RETURN_IF_ERROR(ValidateUtil::validateOver(qctx_, goSentence->overClause(), goCtx_->over));
NG_RETURN_IF_ERROR(extractTagIds());
NG_RETURN_IF_ERROR(validateWhere(goSentence->whereClause()));
NG_RETURN_IF_ERROR(validateYield(goSentence->yieldClause()));
NG_RETURN_IF_ERROR(validateTruncate(goSentence->truncateClause()));
Expand Down Expand Up @@ -86,7 +87,7 @@ Status GoValidator::validateWhere(WhereClause* where) {
return Status::SemanticError(ss.str());
}

NG_RETURN_IF_ERROR(deduceProps(filter, goCtx_->exprProps, nullptr, &goCtx_->over.edgeTypes));
NG_RETURN_IF_ERROR(deduceProps(filter, goCtx_->exprProps, &tagIds_, &goCtx_->over.edgeTypes));
goCtx_->filter = filter;
return Status::OK();
}
Expand Down Expand Up @@ -150,7 +151,7 @@ Status GoValidator::validateYield(YieldClause* yield) {
NG_RETURN_IF_ERROR(typeStatus);
auto type = typeStatus.value();
outputs_.emplace_back(col->name(), type);
NG_RETURN_IF_ERROR(deduceProps(colExpr, exprProps, nullptr, &goCtx_->over.edgeTypes));
NG_RETURN_IF_ERROR(deduceProps(colExpr, exprProps, &tagIds_, &goCtx_->over.edgeTypes));
}

const auto& over = goCtx_->over;
Expand All @@ -165,6 +166,15 @@ Status GoValidator::validateYield(YieldClause* yield) {
return Status::OK();
}

Status GoValidator::extractTagIds() {
auto tagStatus = qctx_->schemaMng()->getAllLatestVerTagSchema(space_.id);
NG_RETURN_IF_ERROR(tagStatus);
for (const auto& tag : tagStatus.value()) {
tagIds_.emplace_back(tag.first);
}
return Status::OK();
}

void GoValidator::extractPropExprs(const Expression* expr,
std::unordered_set<std::string>& uniqueExpr) {
ExtractPropExprVisitor visitor(vctx_,
Expand Down
3 changes: 3 additions & 0 deletions src/graph/validator/GoValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class GoValidator final : public Validator {

Status buildColumns();

Status extractTagIds();

void extractPropExprs(const Expression* expr, std::unordered_set<std::string>& uniqueCols);

Expression* rewrite2VarProp(const Expression* expr);
Expand All @@ -41,6 +43,7 @@ class GoValidator final : public Validator {

YieldColumns* inputPropCols_{nullptr};
std::unordered_map<std::string, YieldColumn*> propExprColMap_;
std::vector<TagID> tagIds_;
};
} // namespace graph
} // namespace nebula
Expand Down
17 changes: 3 additions & 14 deletions src/graph/visitor/DeducePropsVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,23 +184,12 @@ void DeducePropsVisitor::visit(ConstantExpression *expr) { UNUSED(expr); }
void DeducePropsVisitor::visit(ColumnExpression *expr) { UNUSED(expr); }

void DeducePropsVisitor::visit(VertexExpression *expr) {
std::vector<TagID> tagIds;
if (tagIds_ == nullptr) {
auto tagStatus = qctx_->schemaMng()->getAllLatestVerTagSchema(space_);
if (!tagStatus.ok()) {
status_ = std::move(tagStatus).status();
return;
}
for (const auto &tag : tagStatus.value()) {
tagIds.emplace_back(tag.first);
}
} else {
for (const auto &tagID : *tagIds_) {
tagIds.emplace_back(tagID);
}
UNUSED(expr);
return;
}
const auto &colName = expr->name();
for (const auto &tagID : tagIds) {
for (const auto &tagID : *tagIds_) {
const auto &tagSchema = qctx_->schemaMng()->getTagSchema(space_, tagID);
if (colName == "$^") {
exprProps_->insertSrcTagProp(tagID, nebula::kTag);
Expand Down

0 comments on commit 4ac7d4f

Please sign in to comment.