Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Jan 12, 2022
1 parent 24b0337 commit c2d4549
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 37 deletions.
1 change: 0 additions & 1 deletion src/graph/planner/match/LabelIndexSeek.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ StatusOr<SubPlan> LabelIndexSeek::transformNode(NodeContext* nodeCtx) {
storage::cpp2::IndexQueryContext ctx;
ctx.filter_ref() = Expression::encode(*flattenFilter);
scan->setIndexQueryContext({ctx});
whereCtx.reset();
}
}
}
Expand Down
10 changes: 2 additions & 8 deletions src/graph/visitor/VidExtractVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ void VidExtractVisitor::visit(RelationalExpression *expr) {
VidPattern{VidPattern::Special::kInUsed,
{{fCallExpr->args()->args().front()->toString(),
{VidPattern::Vids::Kind::kIn, listExpr->eval(ctx(nullptr)).getList()}}}};
return;
} else if (expr->kind() == Expression::Kind::kRelEQ) {
// id(V) == vid
if (expr->left()->kind() == Expression::Kind::kLabelAttribute) {
Expand Down Expand Up @@ -208,10 +207,9 @@ void VidExtractVisitor::visit(RelationalExpression *expr) {
vidPattern_ = VidPattern{VidPattern::Special::kInUsed,
{{fCallExpr->args()->args().front()->toString(),
{VidPattern::Vids::Kind::kIn, List({constExpr->value()})}}}};
return;
} else {
vidPattern_ = VidPattern{};
return;
vidPattern_ = VidPattern{VidPattern::Special::kInUsed,
{{"", {VidPattern::Vids::Kind::kOtherSource, {}}}}};
}
}

Expand All @@ -227,11 +225,9 @@ void VidExtractVisitor::visit(AttributeExpression *expr) {

void VidExtractVisitor::visit(LogicalExpression *expr) {
if (expr->kind() == Expression::Kind::kLogicalAnd) {
// const auto *expr = static_cast<const LogicalExpression *>(expr);
std::vector<VidPattern> operandsResult;
operandsResult.reserve(expr->operands().size());
for (const auto &operand : expr->operands()) {
// operandsResult.emplace_back(reverseEvalVids(operand.get()));
operand->accept(this);
operandsResult.emplace_back(moveVidPattern());
}
Expand Down Expand Up @@ -287,8 +283,6 @@ void VidExtractVisitor::visit(LogicalExpression *expr) {
vidPattern_ = std::move(inResult);
return;
} else if (expr->kind() == Expression::Kind::kLogicalOr) {
// const auto *andExpr = static_cast<const LogicalExpression
// *>(expr);
std::vector<VidPattern> operandsResult;
operandsResult.reserve(expr->operands().size());
for (const auto &operand : expr->operands()) {
Expand Down
57 changes: 43 additions & 14 deletions tests/tck/features/match/SeekById.feature
Original file line number Diff line number Diff line change
Expand Up @@ -252,42 +252,71 @@ Feature: Match seek by id
"""
Then a ExecutionError should be raised at runtime: Scan vertices or edges need to specify a limit number, or limit number can not push down.

@skip
Scenario: test OR logic (reason = "or logic optimization error")
Scenario: test OR logic
When executing query:
"""
MATCH (v)
WHERE id(v) IN ['James Harden', 'Jonathon Simmons', 'Klay Thompson', 'Dejounte Murray']
OR v.player.age == 23
RETURN v.player.name AS Name
"""
Then the result should be, in any order:
| Name |
| 'James Harden' |
| 'Jonathon Simmons' |
| 'Klay Thompson' |
| 'Dejounte Murray' |
| 'Kristaps Porzingis' |
Then a ExecutionError should be raised at runtime: Scan vertices or edges need to specify a limit number, or limit number can not push down.
When executing query:
"""
MATCH (v)
WHERE id(v) == 'James Harden'
OR v.player.age == 23
RETURN v.player.name AS Name
"""
Then the result should be, in any order:
| Name |
| 'James Harden' |
| 'Kristaps Porzingis' |
Then a ExecutionError should be raised at runtime: Scan vertices or edges need to specify a limit number, or limit number can not push down.
When executing query:
"""
MATCH (v)
WHERE id(v) == 'James Harden'
OR v.player.age != 23
RETURN v.player.name AS Name
"""
Then a ExecutionError should be raised at runtime: Scan vertices or edges need to specify a limit number, or limit number can not push down.
When executing query:
"""
MATCH (v:player)
WHERE v.player.name == "Tim Duncan"
OR v.player.age == 23
RETURN v
"""
Then the result should be, in any order:
| Name |
| v |
| ("Kristaps Porzingis" :player{age: 23, name: "Kristaps Porzingis"}) |
| ("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"}) |
When executing query:
"""
MATCH (v:player)
WHERE v.player.name == "Tim Duncan"
OR v.noexist.age == 23
RETURN v
"""
Then the result should be, in any order:
| v |
| ("Tim Duncan" :bachelor{name: "Tim Duncan", speciality: "psychology"} :player{age: 42, name: "Tim Duncan"}) |
When executing query:
"""
MATCH (v:player)
WHERE v.player.noexist == "Tim Duncan"
OR v.player.age == 23
RETURN v
"""
Then the result should be, in any order:
| v |
| ("Kristaps Porzingis" :player{age: 23, name: "Kristaps Porzingis"}) |
When executing query:
"""
MATCH (v:player)
WHERE v.player.noexist == "Tim Duncan"
OR v.noexist.age == 23
RETURN v
"""
Then the result should be, in any order:
| v |

Scenario: Start from end
When executing query:
Expand Down
57 changes: 43 additions & 14 deletions tests/tck/features/match/SeekById.intVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -245,42 +245,71 @@ Feature: Match seek by id
"""
Then a ExecutionError should be raised at runtime: Scan vertices or edges need to specify a limit number, or limit number can not push down.

@skip
Scenario: test OR logic (reason = "or logic optimization error")
Scenario: test OR logic
When executing query:
"""
MATCH (v)
WHERE id(v) IN [hash('James Harden'), hash('Jonathon Simmons'), hash('Klay Thompson'), hash('Dejounte Murray')]
OR v.player.age == 23
RETURN v.player.name AS Name
"""
Then the result should be, in any order:
| Name |
| 'James Harden' |
| 'Jonathon Simmons' |
| 'Klay Thompson' |
| 'Dejounte Murray' |
| 'Kristaps Porzingis' |
Then a ExecutionError should be raised at runtime: Scan vertices or edges need to specify a limit number, or limit number can not push down.
When executing query:
"""
MATCH (v)
WHERE id(v) == hash('James Harden')
OR v.player.age == 23
RETURN v.player.name AS Name
"""
Then the result should be, in any order:
| Name |
| 'James Harden' |
| 'Kristaps Porzingis' |
Then a ExecutionError should be raised at runtime: Scan vertices or edges need to specify a limit number, or limit number can not push down.
When executing query:
"""
MATCH (v)
WHERE id(v) == hash('James Harden')
OR v.player.age != 23
RETURN v.player.name AS Name
"""
Then a ExecutionError should be raised at runtime: Scan vertices or edges need to specify a limit number, or limit number can not push down.
When executing query:
"""
MATCH (v:player)
WHERE v.player.name == "Tim Duncan"
OR v.player.age == 23
RETURN v.player.name as name
"""
Then the result should be, in any order:
| Name |
| name |
| "Kristaps Porzingis" |
| "Tim Duncan" |
When executing query:
"""
MATCH (v:player)
WHERE v.player.name == "Tim Duncan"
OR v.noexist.age == 23
RETURN v.player.name as name
"""
Then the result should be, in any order:
| name |
| "Tim Duncan" |
When executing query:
"""
MATCH (v:player)
WHERE v.player.noexist == "Tim Duncan"
OR v.player.age == 23
RETURN v.player.name as name
"""
Then the result should be, in any order:
| name |
| "Kristaps Porzingis" |
When executing query:
"""
MATCH (v:player)
WHERE v.player.noexist == "Tim Duncan"
OR v.noexist.age == 23
RETURN v
"""
Then the result should be, in any order:
| v |

Scenario: with arithmetic
When executing query:
Expand Down

0 comments on commit c2d4549

Please sign in to comment.