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

fix match multiple id error #3899

Merged
merged 1 commit into from
Feb 15, 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
5 changes: 1 addition & 4 deletions src/graph/planner/match/VertexIdSeek.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ bool VertexIdSeek::matchNode(NodeContext *nodeCtx) {
if (vidResult.spec != VidExtractVisitor::VidPattern::Special::kInUsed) {
return false;
}
if (vidResult.nodes.size() > 1) {
// where id(v) == 'xxx' or id(t) == 'yyy'
return false;
}

for (auto &nodeVid : vidResult.nodes) {
if (nodeVid.second.kind == VidExtractVisitor::VidPattern::Vids::Kind::kIn) {
if (nodeVid.first == node.alias) {
Expand Down
5 changes: 5 additions & 0 deletions src/graph/visitor/VidExtractVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ void VidExtractVisitor::visit(LogicalExpression *expr) {
}
}
}
// where id(v) == 'xxx' or id(t) == 'yyy'
if (inResult.nodes.size() > 1) {
vidPattern_ = VidPattern{};
return;
}
vidPattern_ = std::move(inResult);
return;
} else {
Expand Down
65 changes: 65 additions & 0 deletions tests/tck/features/match/MatchById.feature
Original file line number Diff line number Diff line change
Expand Up @@ -973,3 +973,68 @@ Feature: Match By Id
| ("Warriors" :team{name: "Warriors"}) |
| ("Hornets" :team{name: "Hornets"}) |
| ("Spurs" :team{name: "Spurs"}) |

Scenario: match by multiple id
When executing query:
"""
MATCH (a)-[e:like]->(b)
WHERE id(a) == 'Tim Duncan' OR id(b) == 'Tony Parker'
Copy link
Contributor

Choose a reason for hiding this comment

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

This should report error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

use like index not vertexIDseek

Copy link
Contributor

Choose a reason for hiding this comment

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

Emm. It's not related to this VIdSeek, better not put in this file.

Copy link
Contributor

Choose a reason for hiding this comment

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

And you should add fail case of or expression.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Emm. It's not related to this VIdSeek, better not put in this file.

it's ok to put this case here

Copy link
Contributor

Choose a reason for hiding this comment

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

Should add integer vid test case too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, add case in next pr

Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't add in this PR directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Sophie-Xie waiting for this PR to publish test version

RETURN id(a) as src, e, id(b) as dst
"""
Then the result should be, in any order, with relax comparison:
| src | e | dst |
| "Tim Duncan" | [:like "Tim Duncan"->"Manu Ginobili" @0 {likeness: 95}] | "Manu Ginobili" |
| "Tim Duncan" | [:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}] | "Tony Parker" |
| "Boris Diaw" | [:like "Boris Diaw"->"Tony Parker" @0 {likeness: 80}] | "Tony Parker" |
| "LaMarcus Aldridge" | [:like "LaMarcus Aldridge"->"Tony Parker" @0 {likeness: 75}] | "Tony Parker" |
| "Dejounte Murray" | [:like "Dejounte Murray"->"Tony Parker" @0 {likeness: 99}] | "Tony Parker" |
| "Marco Belinelli" | [:like "Marco Belinelli"->"Tony Parker" @0 {likeness: 50}] | "Tony Parker" |
When executing query:
"""
MATCH (a)-[e:like]->(b)
WHERE id(a) == 'Tim Duncan' AND id(b) == 'Tony Parker'
RETURN id(a) as src, e, id(b) as dst
"""
Then the result should be, in any order, with relax comparison:
| src | e | dst |
| "Tim Duncan" | [:like "Tim Duncan"->"Tony Parker" @0 {likeness: 95}] | "Tony Parker" |
When executing query:
"""
MATCH (a)--(b)
WHERE id(a) == 'Tim Duncan' AND id(b) == 'Tony Parker'
RETURN id(a) as src, id(b) as dst
"""
Then the result should be, in any order, with relax comparison:
| src | dst |
| "Tim Duncan" | "Tony Parker" |
| "Tim Duncan" | "Tony Parker" |
| "Tim Duncan" | "Tony Parker" |
| "Tim Duncan" | "Tony Parker" |
When executing query:
"""
MATCH (v1)-[:like]->(v2:player)-[:serve]->(v3)
WHERE id(v3) == 'Spurs' AND id(v1) == 'Tony Parker'
RETURN v1, v2, v3
"""
Then the result should be, in any order, with relax comparison:
| v1 | v2 | v3 |
| ("Tony Parker" :player{age: 36, name: "Tony Parker"}) | ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"}) | ("Spurs" :team{name: "Spurs"}) |
| ("Tony Parker" :player{age: 36, name: "Tony Parker"}) | ("LaMarcus Aldridge" :player{age: 33, name: "LaMarcus Aldridge"}) | ("Spurs" :team{name: "Spurs"}) |
| ("Tony Parker" :player{age: 36, name: "Tony Parker"}) | ("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"}) | ("Spurs" :team{name: "Spurs"}) |
When executing query:
"""
MATCH (a)--(b) WHERE id(b) == 'Tony Parker' RETURN DISTINCT id(a)
UNION
MATCH (a)--(b) WHERE id(b) == 'Tony Parker' RETURN DISTINCT id(a)
"""
Then the result should be, in any order, with relax comparison:
| id(a) |
| "Hornets" |
| "Marco Belinelli" |
| "Spurs" |
| "Dejounte Murray" |
| "Tim Duncan" |
| "Boris Diaw" |
| "Manu Ginobili" |
| "Kyle Anderson" |
| "LaMarcus Aldridge" |