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

Allow the expressions like 'v.tag' in return #5440

Merged
merged 9 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from 8 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
15 changes: 12 additions & 3 deletions src/graph/visitor/PropertyTrackerVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,19 @@ 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
auto *varPropExpr = static_cast<PropertyExpression *>(lhs);
auto &edgeAlias = varPropExpr->prop();
propsUsed_.insertEdgeProp(edgeAlias, unknownType_, propName);
auto &entityAlias = varPropExpr->prop();
propsUsed_.insertEdgeProp(entityAlias, unknownType_, propName);
// maybe: $v.tag
auto ret = qctx_->schemaMng()->toTagID(space_, propName);
if (!ret.ok()) {
status_ = std::move(ret).status();
break;
}
auto tagId = ret.value();
propsUsed_.insertVertexProp(entityAlias, tagId, "*");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to insert edge and vertex props at same time? maybe only need to handle one branch by checking where the prop is from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just found e.likeness wouldn't reach here... Maybe this part was outdated. Let me check.

Copy link
Contributor Author

@xtcyclist xtcyclist Mar 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It goes into Kind::kSubscript as $-.e[0]. Maybe we can delete it already. 算了,不敢删。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we don't have sufficient information here to tell them apart. Any advise?

break;
}
case Expression::Kind::kCase: { // (case xxx).name
Expand Down
6 changes: 5 additions & 1 deletion src/graph/visitor/PrunePropertiesVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
usedProps.insert(props.begin(), props.end());
} else {
usedProps.insert(tagIter->second.begin(), tagIter->second.end());
}
}
if (usedProps.empty()) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions tests/tck/features/match/Base.IntVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions tests/tck/features/match/Base.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1449,8 +1449,17 @@ 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)
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
Expand Down