Skip to content

Commit

Permalink
update tck.
Browse files Browse the repository at this point in the history
  • Loading branch information
xtcyclist committed Dec 2, 2022
1 parent 3ddce2e commit 9983c2a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 30 deletions.
13 changes: 6 additions & 7 deletions src/graph/executor/query/TopNExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,16 @@ folly::Future<Status> TopNExecutor::execute() {
maxCount_ = size - offset_;
heapSize_ = size;
}
for (auto &idx : topn->inputVars()[0]->invisibleColIndicies) {
result.valuePtr()->getMutableDataSet().removeColumn(idx);
}

if (heapSize_ == 0) {
iter->clear();
return finish(ResultBuilder().value(result.valuePtr()).iter(std::move(result).iter()).build());
} else {
executeTopN<SequentialIter>(iter);
iter->eraseRange(maxCount_, size);
}
for (auto &idx : topn->inputVars()[0]->invisibleColIndicies) {
result.valuePtr()->getMutableDataSet().removeColumn(idx);
}

executeTopN<SequentialIter>(iter);
iter->eraseRange(maxCount_, size);
return finish(ResultBuilder().value(result.valuePtr()).iter(std::move(result).iter()).build());
}

Expand Down
86 changes: 63 additions & 23 deletions tests/tck/features/match/OrderBy.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ Feature: OrderBy in Match
Given a graph with space named "nba"

Scenario: orderby hidden column
When executing query:
"""
match (v:player)-->(v1)
with v, v1, count(v1) as a0
where a0 > 1
return sum(v.player.age)
order by a0
limit 5
"""
Then a SemanticError should be raised at runtime: Column `a0' not found
When executing query:
"""
match (v:player)-->(v1)
with v, v1, count(v1) as a0
where a0 > 1
return distinct v
order by a0
limit 5
"""
Then a SemanticError should be raised at runtime: Column `a0' not found
When executing query:
"""
match (v:player)-->(v1:player)
Expand All @@ -15,7 +35,7 @@ Feature: OrderBy in Match
return v, v1
order by a0, name
"""
Then the result should be:
Then the result should be, in order:
| v | v1 |
| ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"}) | ("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"}) |
| ("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"}) | ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"}) |
Expand All @@ -24,47 +44,67 @@ Feature: OrderBy in Match
| ("Tony Parker" :player{age: 36, name: "Tony Parker"}) | ("LaMarcus Aldridge" :player{age: 33, name: "LaMarcus Aldridge"}) |
| ("Tony Parker" :player{age: 36, name: "Tony Parker"}) | ("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"}) |

@skip
Scenario: skip after orderby hidden column
Scenario: topn hidden column
When executing query:
"""
match (v:player)-->(v1:player)
with v, v1, v.player.name as name, count(v) as a0
where a0 > 0
return name
order by a0, name desc
order by a0 desc, name desc
limit 10
"""
Then the result should be:
Then the result should be, in order:
| name |
| "Tony Parker" |
| "Tony Parker" |
| "Tony Parker" |
| "Tim Duncan" |
| "Tim Duncan" |
| "Manu Ginobili" |
| "Yao Ming" |
| "Yao Ming" |
| "Vince Carter" |
| "Vince Carter" |
| "Tracy McGrady" |
| "Tracy McGrady" |
| "Tracy McGrady" |
| "Tony Parker" |
| "Tim Duncan" |
| "Tim Duncan" |
When executing query:
"""
match (v:player)-->(v1:player)
with v, v1, v.player.name as name, count(v) as a0
where a0 > 0
return a0, name
order by a0 desc, name desc
limit 10
"""
Then the result should be, in order:
| a0 | name |
| 2 | "Tony Parker" |
| 2 | "Tony Parker" |
| 2 | "Tony Parker" |
| 2 | "Tim Duncan" |
| 2 | "Tim Duncan" |
| 2 | "Manu Ginobili" |
| 1 | "Yao Ming" |
| 1 | "Yao Ming" |
| 1 | "Vince Carter" |
| 1 | "Vince Carter" |

Scenario: orderby return column
When executing query:
"""
match (v:player)-->(v1:player)
with v, v1, v.player.name as name, count(v) as a0
with v, v1, v.player.age as age0, v1.player.age as age1, count(v) as a0
where a0 > 1
return v, v1, a0
order by a0, name
return age0, age1
order by age0, age1
"""
Then the result should be:
| v | v1 | a0 |
| ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"}) | ("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"}) | 2 |
| ("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"}) | ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"}) | 2 |
| ("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"}) | ("Tony Parker" :player{age: 36, name: "Tony Parker"}) | 2 |
| ("Tony Parker" :player{age: 36, name: "Tony Parker"}) | ("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"}) | 2 |
| ("Tony Parker" :player{age: 36, name: "Tony Parker"}) | ("LaMarcus Aldridge" :player{age: 33, name: "LaMarcus Aldridge"}) | 2 |
| ("Tony Parker" :player{age: 36, name: "Tony Parker"}) | ("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"}) | 2 |
Then the result should be, in order:
| age0 | age1 |
| 36 | 33 |
| 36 | 41 |
| 36 | 42 |
| 41 | 42 |
| 42 | 36 |
| 42 | 41 |
When executing query:
"""
match (v:player)-->(v1:player)
Expand All @@ -73,7 +113,7 @@ Feature: OrderBy in Match
return name, a0
order by a0, name desc
"""
Then the result should be:
Then the result should be, in order:
| name | a0 |
| "Tony Parker" | 2 |
| "Tony Parker" | 2 |
Expand Down

0 comments on commit 9983c2a

Please sign in to comment.