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

Avoid duplicate columns in return #5443

Merged
merged 2 commits into from
Mar 28, 2023
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: 4 additions & 1 deletion src/graph/validator/MatchValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ Status MatchValidator::buildColumnsForAllNamedAliases(const std::vector<QueryPar
auto *expr = LabelExpression::make(pool, name);
return new YieldColumn(expr, name);
};
std::set<std::string> visitedAliases;
auto &currQueryPart = queryParts.back();
if (queryParts.size() > 1) {
auto &prevQueryPart = *(queryParts.end() - 2);
Expand All @@ -396,9 +397,11 @@ Status MatchValidator::buildColumnsForAllNamedAliases(const std::vector<QueryPar
columns->addColumn(makeColumn(unwindCtx->alias), true);
for (auto &passAlias : prevQueryPart.aliasesAvailable) {
columns->addColumn(makeColumn(passAlias.first), true);
visitedAliases.emplace(passAlias.first);
}
for (auto &passAlias : prevQueryPart.aliasesGenerated) {
columns->addColumn(makeColumn(passAlias.first), true);
visitedAliases.emplace(passAlias.first);
}
break;
}
Expand All @@ -411,6 +414,7 @@ Status MatchValidator::buildColumnsForAllNamedAliases(const std::vector<QueryPar
for (auto &col : yieldColumns->columns()) {
if (!col->alias().empty()) {
columns->addColumn(makeColumn(col->alias()), true);
visitedAliases.emplace(col->alias());
}
}
break;
Expand All @@ -421,7 +425,6 @@ Status MatchValidator::buildColumnsForAllNamedAliases(const std::vector<QueryPar
}
}

std::set<std::string> visitedAliases;
for (auto &match : currQueryPart.matchs) {
for (auto &path : match->paths) {
for (size_t i = 0; i < path.edgeInfos.size(); ++i) {
Expand Down
47 changes: 47 additions & 0 deletions tests/tck/features/match/With.feature
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,50 @@ Feature: With clause
with [1,2] as a unwind a as b match (b)-[e:like]->(a:player{age:30}) return b
"""
Then a ExecutionError should be raised at runtime: Argument only support vertex, but got 1, which is type int

Scenario: duplicate columns
When executing query:
"""
match (v:player{name:"Tim Duncan"})-[e:like]-(v2)
with v2, sum(e.likeness) as likeness
match (v2)-[:serve]-(v3)
return *
"""
Then the result should be, in any order:
| v2 | likeness | v3 |
| ("Tony Parker" :player{age: 36, name: "Tony Parker"}) | 190 | ("Hornets" :team{}) |
| ("Tony Parker" :player{age: 36, name: "Tony Parker"}) | 190 | ("Spurs" :team{}) |
| ("Aron Baynes" :player{age: 32, name: "Aron Baynes"}) | 80 | ("Celtics" :team{}) |
| ("Aron Baynes" :player{age: 32, name: "Aron Baynes"}) | 80 | ("Pistons" :team{}) |
| ("Aron Baynes" :player{age: 32, name: "Aron Baynes"}) | 80 | ("Spurs" :team{}) |
| ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"}) | 185 | ("Spurs" :team{}) |
| ("Boris Diaw" :player{age: 36, name: "Boris Diaw"}) | 80 | ("Hawks" :team{}) |
| ("Boris Diaw" :player{age: 36, name: "Boris Diaw"}) | 80 | ("Hornets" :team{}) |
| ("Boris Diaw" :player{age: 36, name: "Boris Diaw"}) | 80 | ("Jazz" :team{}) |
| ("Boris Diaw" :player{age: 36, name: "Boris Diaw"}) | 80 | ("Spurs" :team{}) |
| ("Boris Diaw" :player{age: 36, name: "Boris Diaw"}) | 80 | ("Suns" :team{}) |
| ("LaMarcus Aldridge" :player{age: 33, name: "LaMarcus Aldridge"}) | 75 | ("Spurs" :team{}) |
| ("LaMarcus Aldridge" :player{age: 33, name: "LaMarcus Aldridge"}) | 75 | ("Trail Blazers" :team{}) |
| ("Danny Green" :player{age: 31, name: "Danny Green"}) | 70 | ("Cavaliers" :team{}) |
| ("Danny Green" :player{age: 31, name: "Danny Green"}) | 70 | ("Raptors" :team{}) |
| ("Danny Green" :player{age: 31, name: "Danny Green"}) | 70 | ("Spurs" :team{}) |
| ("Dejounte Murray" :player{age: 29, name: "Dejounte Murray"}) | 99 | ("Spurs" :team{}) |
| ("Marco Belinelli" :player{age: 32, name: "Marco Belinelli"}) | 55 | ("76ers" :team{}) |
| ("Marco Belinelli" :player{age: 32, name: "Marco Belinelli"}) | 55 | ("Bulls" :team{}) |
| ("Marco Belinelli" :player{age: 32, name: "Marco Belinelli"}) | 55 | ("Hawks" :team{}) |
| ("Marco Belinelli" :player{age: 32, name: "Marco Belinelli"}) | 55 | ("Hornets" :team{}) |
| ("Marco Belinelli" :player{age: 32, name: "Marco Belinelli"}) | 55 | ("Kings" :team{}) |
| ("Marco Belinelli" :player{age: 32, name: "Marco Belinelli"}) | 55 | ("Raptors" :team{}) |
| ("Marco Belinelli" :player{age: 32, name: "Marco Belinelli"}) | 55 | ("Spurs" :team{}) |
| ("Marco Belinelli" :player{age: 32, name: "Marco Belinelli"}) | 55 | ("Warriors" :team{}) |
| ("Marco Belinelli" :player{age: 32, name: "Marco Belinelli"}) | 55 | ("Hornets" :team{}) |
| ("Marco Belinelli" :player{age: 32, name: "Marco Belinelli"}) | 55 | ("Spurs" :team{}) |
| ("Shaquille O'Neal" :player{age: 47, name: "Shaquille O'Neal"}) | 80 | ("Cavaliers" :team{}) |
| ("Shaquille O'Neal" :player{age: 47, name: "Shaquille O'Neal"}) | 80 | ("Celtics" :team{}) |
| ("Shaquille O'Neal" :player{age: 47, name: "Shaquille O'Neal"}) | 80 | ("Heat" :team{}) |
| ("Shaquille O'Neal" :player{age: 47, name: "Shaquille O'Neal"}) | 80 | ("Lakers" :team{}) |
| ("Shaquille O'Neal" :player{age: 47, name: "Shaquille O'Neal"}) | 80 | ("Magic" :team{}) |
| ("Shaquille O'Neal" :player{age: 47, name: "Shaquille O'Neal"}) | 80 | ("Suns" :team{}) |
| ("Tiago Splitter" :player{age: 34, name: "Tiago Splitter"}) | 80 | ("76ers" :team{}) |
| ("Tiago Splitter" :player{age: 34, name: "Tiago Splitter"}) | 80 | ("Hawks" :team{}) |
| ("Tiago Splitter" :player{age: 34, name: "Tiago Splitter"}) | 80 | ("Spurs" :team{}) |