From 7e1a63bdc2236c364af6fa1645950583ac1b3cd8 Mon Sep 17 00:00:00 2001 From: xtcyclist <7731943+xtcyclist@users.noreply.github.com> Date: Mon, 27 Mar 2023 17:41:44 +0800 Subject: [PATCH] fix return v.tag --- src/graph/visitor/PropertyTrackerVisitor.cpp | 16 +++++++++++++--- src/graph/visitor/PrunePropertiesVisitor.cpp | 10 ++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/graph/visitor/PropertyTrackerVisitor.cpp b/src/graph/visitor/PropertyTrackerVisitor.cpp index ede1c764fea..f22f199f6de 100644 --- a/src/graph/visitor/PropertyTrackerVisitor.cpp +++ b/src/graph/visitor/PropertyTrackerVisitor.cpp @@ -208,10 +208,20 @@ void PropertyTrackerVisitor::visit(AttributeExpression *expr) { auto &propName = constVal.getStr(); switch (lhs->kind()) { case Expression::Kind::kInputProperty: - case Expression::Kind::kVarProperty: { // $e.name + case Expression::Kind::kVarProperty: { + // maybe: $e.prop or $v.tag auto *varPropExpr = static_cast(lhs); - auto &edgeAlias = varPropExpr->prop(); - propsUsed_.insertEdgeProp(edgeAlias, unknownType_, propName); + auto &entityAlias = varPropExpr->prop(); + propsUsed_.insertEdgeProp(entityAlias, unknownType_, propName); + // $v.tag + auto &tagName = propName; + auto ret = qctx_->schemaMng()->toTagID(space_, tagName); + if (!ret.ok()) { + status_ = std::move(ret).status(); + return; + } + auto tagId = ret.value(); + propsUsed_.insertVertexProp(entityAlias, tagId, "*"); break; } case Expression::Kind::kCase: { // (case xxx).name diff --git a/src/graph/visitor/PrunePropertiesVisitor.cpp b/src/graph/visitor/PrunePropertiesVisitor.cpp index 4eeba769895..e9da5e02704 100644 --- a/src/graph/visitor/PrunePropertiesVisitor.cpp +++ b/src/graph/visitor/PrunePropertiesVisitor.cpp @@ -420,7 +420,11 @@ void PrunePropertiesVisitor::pruneCurrent(AppendVertices *node) { usedProps.insert(unknownIter->second.begin(), unknownIter->second.end()); } if (tagIter != usedVertexProps.end()) { - usedProps.insert(tagIter->second.begin(), tagIter->second.end()); + if (tagIter->second.find("*") != tagIter->second.end()) { + continue; + } else { + usedProps.insert(tagIter->second.begin(), tagIter->second.end()); + } } if (usedProps.empty()) { continue; @@ -439,7 +443,9 @@ void PrunePropertiesVisitor::pruneCurrent(AppendVertices *node) { newVProp.props_ref() = std::move(newProps); prunedVertexProps->emplace_back(std::move(newVProp)); } - node->setVertexProps(std::move(prunedVertexProps)); + if (!prunedVertexProps->empty()) { + node->setVertexProps(std::move(prunedVertexProps)); + } } void PrunePropertiesVisitor::visit(HashJoin *node) {