forked from vesoft-inc/nebula-graph
/
MatchValidatorTest.cpp
80 lines (74 loc) · 4.05 KB
/
MatchValidatorTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* Copyright (c) 2020 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License,
* attached with Common Clause Condition 1.0, found in the LICENSES directory.
*/
#include "validator/MatchValidator.h"
#include "validator/test/ValidatorTestBase.h"
namespace nebula {
namespace graph {
class MatchValidatorTest : public ValidatorTestBase {};
TEST_F(MatchValidatorTest, SeekByTagIndex) {
// empty properties index
{
std::string query = "MATCH (v:person) RETURN id(v) AS id;";
std::vector<PlanNode::Kind> expected = {PlanNode::Kind::kProject,
PlanNode::Kind::kFilter,
PlanNode::Kind::kProject,
PlanNode::Kind::kProject,
// TODO this tag filter could remove in this case
PlanNode::Kind::kFilter,
PlanNode::Kind::kGetVertices,
PlanNode::Kind::kDedup,
PlanNode::Kind::kProject,
PlanNode::Kind::kIndexScan,
PlanNode::Kind::kStart};
EXPECT_TRUE(checkResult(query, expected));
}
// non empty properties index
{
std::string query = "MATCH (v:book) RETURN id(v) AS id;";
std::vector<PlanNode::Kind> expected = {PlanNode::Kind::kProject,
PlanNode::Kind::kFilter,
PlanNode::Kind::kProject,
PlanNode::Kind::kProject,
// TODO this tag filter could remove in this case
PlanNode::Kind::kFilter,
PlanNode::Kind::kGetVertices,
PlanNode::Kind::kDedup,
PlanNode::Kind::kProject,
PlanNode::Kind::kIndexScan,
PlanNode::Kind::kStart};
EXPECT_TRUE(checkResult(query, expected));
}
// non empty properties index with extend
{
std::string query = "MATCH (p:person)-[:like]->(b:book) RETURN b.name AS book;";
std::vector<PlanNode::Kind> expected = {PlanNode::Kind::kProject,
PlanNode::Kind::kFilter,
PlanNode::Kind::kProject,
PlanNode::Kind::kDataJoin,
PlanNode::Kind::kProject,
PlanNode::Kind::kFilter,
PlanNode::Kind::kGetVertices,
PlanNode::Kind::kDedup,
PlanNode::Kind::kProject,
PlanNode::Kind::kFilter,
PlanNode::Kind::kPassThrough,
PlanNode::Kind::kProject,
PlanNode::Kind::kFilter,
PlanNode::Kind::kGetNeighbors,
PlanNode::Kind::kDedup,
PlanNode::Kind::kProject,
PlanNode::Kind::kIndexScan,
PlanNode::Kind::kStart};
EXPECT_TRUE(checkResult(query, expected));
}
// non index
{
std::string query = "MATCH (v:room) RETURN id(v) AS id;";
EXPECT_FALSE(validate(query));
}
}
} // namespace graph
} // namespace nebula