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

[SIMPLE]Fix prune properties #3933

Merged
merged 5 commits into from
Feb 24, 2022
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
1 change: 1 addition & 0 deletions src/graph/planner/plan/PlanNodeVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class PlanNodeVisitor {
virtual void visit(Aggregate *node) = 0;
virtual void visit(Traverse *node) = 0;
virtual void visit(AppendVertices *node) = 0;
virtual void visit(Dedup *node) = 0;
virtual void visit(BiJoin *node) = 0;
};

Expand Down
4 changes: 4 additions & 0 deletions src/graph/planner/plan/Query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,10 @@ Dedup::Dedup(QueryContext* qctx, PlanNode* input) : SingleInputNode(qctx, Kind::
copyInputColNames(input);
}

void Dedup::accept(PlanNodeVisitor* visitor) {
visitor->visit(this);
}

PlanNode* Dedup::clone() const {
auto* newDedup = Dedup::make(qctx_, nullptr);
newDedup->cloneMembers(*this);
Expand Down
2 changes: 2 additions & 0 deletions src/graph/planner/plan/Query.h
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,8 @@ class Dedup final : public SingleInputNode {
return qctx->objPool()->add(new Dedup(qctx, input));
}

void accept(PlanNodeVisitor* visitor) override;

PlanNode* clone() const override;

private:
Expand Down
6 changes: 6 additions & 0 deletions src/graph/visitor/PropertyTrackerVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ Status PropertyTracker::update(const std::string &oldName, const std::string &ne
return Status::Error("Duplicated property name: %s", oldName.c_str());
}
if (hasNodeAlias) {
if (vertexPropsMap.find(newName) != vertexPropsMap.end()) {
return Status::Error("Property name %s conflicted with %s", newName.c_str(), oldName.c_str());
}
vertexPropsMap[newName] = std::move(it1->second);
vertexPropsMap.erase(it1);
}
if (hasEdgeAlias) {
if (edgePropsMap.find(newName) != edgePropsMap.end()) {
return Status::Error("Property name %s conflicted with %s", newName.c_str(), oldName.c_str());
}
edgePropsMap[newName] = std::move(it2->second);
edgePropsMap.erase(it2);
}
Expand Down
15 changes: 14 additions & 1 deletion src/graph/visitor/PrunePropertiesVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ void PrunePropertiesVisitor::visit(AppendVertices *node) {

if (node->vFilter() != nullptr) {
status_ = extractPropsFromExpr(node->vFilter(), nodeAlias);
return;
if (!status_.ok()) {
return;
}
}
auto *vertexProps = node->props();
if (vertexProps != nullptr) {
Expand Down Expand Up @@ -250,6 +252,14 @@ void PrunePropertiesVisitor::visit(AppendVertices *node) {
status_ = depsPruneProperties(node->dependencies());
}

void PrunePropertiesVisitor::visit(Dedup *node) {
const auto &colNames = qctx_->symTable()->getVar(node->inputVar())->colNames;
for (auto &colName : colNames) {
propsUsed_.colsSet.insert(colName);
}
status_ = depsPruneProperties(node->dependencies());
}

void PrunePropertiesVisitor::visit(BiJoin *node) {
for (auto *hashKey : node->hashKeys()) {
status_ = extractPropsFromExpr(hashKey);
Expand All @@ -269,6 +279,9 @@ void PrunePropertiesVisitor::visit(BiJoin *node) {
Status PrunePropertiesVisitor::depsPruneProperties(std::vector<const PlanNode *> &dependencies) {
for (const auto *dep : dependencies) {
const_cast<PlanNode *>(dep)->accept(this);
if (!status_.ok()) {
return status_;
}
}
return Status::OK();
}
Expand Down
1 change: 1 addition & 0 deletions src/graph/visitor/PrunePropertiesVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class PrunePropertiesVisitor final : public PlanNodeVisitor {
void visit(Aggregate *node) override;
void visit(Traverse *node) override;
void visit(AppendVertices *node) override;
void visit(Dedup *node) override;
void visit(BiJoin *node) override;

private:
Expand Down