From 9e75c674826d083cbd47d9eeaa5d6d3116d0b7a3 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 1/7] 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 f36c288b2dd..0d3890a9098 100644 --- a/src/graph/visitor/PrunePropertiesVisitor.cpp +++ b/src/graph/visitor/PrunePropertiesVisitor.cpp @@ -424,7 +424,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; @@ -443,7 +447,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) { From 0dc259280f8f56cc2b1ad9e1a2e6776024aa8d74 Mon Sep 17 00:00:00 2001 From: xtcyclist <7731943+xtcyclist@users.noreply.github.com> Date: Mon, 27 Mar 2023 17:47:25 +0800 Subject: [PATCH 2/7] add tck. --- tests/tck/features/match/Base.IntVid.feature | 4 ++-- tests/tck/features/match/Base.feature | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/tck/features/match/Base.IntVid.feature b/tests/tck/features/match/Base.IntVid.feature index d45577d3ca5..ae1318655ff 100644 --- a/tests/tck/features/match/Base.IntVid.feature +++ b/tests/tck/features/match/Base.IntVid.feature @@ -1045,8 +1045,8 @@ Feature: Basic match MATCH (v:player{name:"Tim Duncan"}) RETURN v.player AS vtag """ Then the result should be, in any order: - | vtag | - | {name:"Tim Duncan"} | + | vtag | + | {age: 42, name: "Tim Duncan"} | When executing query: """ MATCH (v:player)-[]->(b) WHERE v.age > 30 RETURN v.player.name AS vname diff --git a/tests/tck/features/match/Base.feature b/tests/tck/features/match/Base.feature index 8295915e923..6e415c53f2a 100644 --- a/tests/tck/features/match/Base.feature +++ b/tests/tck/features/match/Base.feature @@ -1449,8 +1449,8 @@ Feature: Basic match MATCH (v:player{name:"Tim Duncan"}) RETURN v.player AS vtag """ Then the result should be, in any order: - | vtag | - | {name:"Tim Duncan"} | + | vtag | + | {age: 42, name: "Tim Duncan"} | When executing query: """ MATCH (v:player)-[]->(b) WHERE v.age > 30 RETURN v.player.name AS vname From 873149c154879831d5d2b6bcb22d27be1ee48fa8 Mon Sep 17 00:00:00 2001 From: xtcyclist <7731943+xtcyclist@users.noreply.github.com> Date: Mon, 27 Mar 2023 18:02:37 +0800 Subject: [PATCH 3/7] minor --- src/graph/visitor/PropertyTrackerVisitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graph/visitor/PropertyTrackerVisitor.cpp b/src/graph/visitor/PropertyTrackerVisitor.cpp index f22f199f6de..f37da758482 100644 --- a/src/graph/visitor/PropertyTrackerVisitor.cpp +++ b/src/graph/visitor/PropertyTrackerVisitor.cpp @@ -218,7 +218,7 @@ void PropertyTrackerVisitor::visit(AttributeExpression *expr) { auto ret = qctx_->schemaMng()->toTagID(space_, tagName); if (!ret.ok()) { status_ = std::move(ret).status(); - return; + break; } auto tagId = ret.value(); propsUsed_.insertVertexProp(entityAlias, tagId, "*"); From 938e2132ebb67978c9df64a994c929f28044e14b Mon Sep 17 00:00:00 2001 From: xtcyclist <7731943+xtcyclist@users.noreply.github.com> Date: Mon, 27 Mar 2023 18:04:55 +0800 Subject: [PATCH 4/7] minor --- src/graph/visitor/PropertyTrackerVisitor.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/graph/visitor/PropertyTrackerVisitor.cpp b/src/graph/visitor/PropertyTrackerVisitor.cpp index f37da758482..3e20f09f8e7 100644 --- a/src/graph/visitor/PropertyTrackerVisitor.cpp +++ b/src/graph/visitor/PropertyTrackerVisitor.cpp @@ -209,13 +209,12 @@ void PropertyTrackerVisitor::visit(AttributeExpression *expr) { switch (lhs->kind()) { case Expression::Kind::kInputProperty: case Expression::Kind::kVarProperty: { - // maybe: $e.prop or $v.tag + // maybe: $e.prop auto *varPropExpr = static_cast(lhs); auto &entityAlias = varPropExpr->prop(); propsUsed_.insertEdgeProp(entityAlias, unknownType_, propName); - // $v.tag - auto &tagName = propName; - auto ret = qctx_->schemaMng()->toTagID(space_, tagName); + // maybe: $v.tag + auto ret = qctx_->schemaMng()->toTagID(space_, propName); if (!ret.ok()) { status_ = std::move(ret).status(); break; From c53a82a75d310f1f10b5ad931b82ea77b1baddf2 Mon Sep 17 00:00:00 2001 From: xtcyclist <7731943+xtcyclist@users.noreply.github.com> Date: Mon, 27 Mar 2023 19:14:42 +0800 Subject: [PATCH 5/7] minor --- src/graph/visitor/PrunePropertiesVisitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graph/visitor/PrunePropertiesVisitor.cpp b/src/graph/visitor/PrunePropertiesVisitor.cpp index 0d3890a9098..2e79ff819ce 100644 --- a/src/graph/visitor/PrunePropertiesVisitor.cpp +++ b/src/graph/visitor/PrunePropertiesVisitor.cpp @@ -425,7 +425,7 @@ void PrunePropertiesVisitor::pruneCurrent(AppendVertices *node) { } if (tagIter != usedVertexProps.end()) { if (tagIter->second.find("*") != tagIter->second.end()) { - continue; + usedProps.insert(props.begin(), props.end()); } else { usedProps.insert(tagIter->second.begin(), tagIter->second.end()); } From 52c9de50b9bfe577aeae2ac9f54ba4c6fe94fd0d Mon Sep 17 00:00:00 2001 From: xtcyclist <7731943+xtcyclist@users.noreply.github.com> Date: Mon, 27 Mar 2023 19:16:26 +0800 Subject: [PATCH 6/7] update tck. --- tests/tck/features/match/Base.feature | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/tck/features/match/Base.feature b/tests/tck/features/match/Base.feature index 6e415c53f2a..5ebdcef3dd8 100644 --- a/tests/tck/features/match/Base.feature +++ b/tests/tck/features/match/Base.feature @@ -1451,6 +1451,15 @@ Feature: Basic match Then the result should be, in any order: | vtag | | {age: 42, name: "Tim Duncan"} | + When executing query: + """ + match (v) + where id(v) == "Tim Duncan" + return v.player, v.bachelor.name + """ + Then the result should be, in any order: + | v.player | v.bachelor.name | + | {age: 42, name: "Tim Duncan"} | "Tim Duncan" | When executing query: """ MATCH (v:player)-[]->(b) WHERE v.age > 30 RETURN v.player.name AS vname From 148931c3d51775f377ef06b809e75448017074d0 Mon Sep 17 00:00:00 2001 From: xtcyclist <7731943+xtcyclist@users.noreply.github.com> Date: Mon, 27 Mar 2023 19:17:23 +0800 Subject: [PATCH 7/7] minor --- src/graph/visitor/PrunePropertiesVisitor.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/graph/visitor/PrunePropertiesVisitor.cpp b/src/graph/visitor/PrunePropertiesVisitor.cpp index 2e79ff819ce..9daed3f1626 100644 --- a/src/graph/visitor/PrunePropertiesVisitor.cpp +++ b/src/graph/visitor/PrunePropertiesVisitor.cpp @@ -447,9 +447,7 @@ void PrunePropertiesVisitor::pruneCurrent(AppendVertices *node) { newVProp.props_ref() = std::move(newProps); prunedVertexProps->emplace_back(std::move(newVProp)); } - if (!prunedVertexProps->empty()) { - node->setVertexProps(std::move(prunedVertexProps)); - } + node->setVertexProps(std::move(prunedVertexProps)); } void PrunePropertiesVisitor::visit(HashJoin *node) {