Rename directions from LEFT/RIGHT to IN/OUT
Reviewers: florijan, mislav.bradac Reviewed By: mislav.bradac Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D405
This commit is contained in:
parent
f9bcd6d760
commit
e631eb4eb2
@ -679,10 +679,7 @@ class EdgeAtom : public PatternAtom {
|
||||
friend class AstTreeStorage;
|
||||
|
||||
public:
|
||||
// TODO change to IN, OUT, BOTH
|
||||
// LEFT/RIGHT is not clear especially when expansion will not
|
||||
// necessarily go from left to right
|
||||
enum class Direction { LEFT, RIGHT, BOTH };
|
||||
enum class Direction { IN, OUT, BOTH };
|
||||
|
||||
DEFVISITABLE(TreeVisitor<TypedValue>);
|
||||
bool Accept(HierarchicalTreeVisitor &visitor) override {
|
||||
|
@ -419,9 +419,9 @@ antlrcpp::Any CypherMainVisitor::visitRelationshipPattern(
|
||||
}
|
||||
|
||||
if (ctx->leftArrowHead() && !ctx->rightArrowHead()) {
|
||||
edge->direction_ = EdgeAtom::Direction::LEFT;
|
||||
edge->direction_ = EdgeAtom::Direction::IN;
|
||||
} else if (!ctx->leftArrowHead() && ctx->rightArrowHead()) {
|
||||
edge->direction_ = EdgeAtom::Direction::RIGHT;
|
||||
edge->direction_ = EdgeAtom::Direction::OUT;
|
||||
} else {
|
||||
// <-[]-> and -[]- is the same thing as far as we understand openCypher
|
||||
// grammar.
|
||||
|
@ -111,10 +111,10 @@ bool CreateExpand::CreateExpandCursor::Pull(Frame &frame,
|
||||
|
||||
// create an edge between the two nodes
|
||||
switch (self_.edge_atom_->direction_) {
|
||||
case EdgeAtom::Direction::LEFT:
|
||||
case EdgeAtom::Direction::IN:
|
||||
CreateEdge(v2, v1, frame, symbol_table, evaluator);
|
||||
break;
|
||||
case EdgeAtom::Direction::RIGHT:
|
||||
case EdgeAtom::Direction::OUT:
|
||||
CreateEdge(v1, v2, frame, symbol_table, evaluator);
|
||||
break;
|
||||
case EdgeAtom::Direction::BOTH:
|
||||
@ -275,7 +275,7 @@ bool Expand::ExpandCursor::Pull(Frame &frame, const SymbolTable &symbol_table) {
|
||||
if (in_edges_ && *in_edges_it_ != in_edges_->end()) {
|
||||
EdgeAccessor edge = *(*in_edges_it_)++;
|
||||
if (HandleExistingEdge(edge, frame, symbol_table) &&
|
||||
PullNode(edge, EdgeAtom::Direction::LEFT, frame, symbol_table))
|
||||
PullNode(edge, EdgeAtom::Direction::IN, frame, symbol_table))
|
||||
return true;
|
||||
else
|
||||
continue;
|
||||
@ -290,7 +290,7 @@ bool Expand::ExpandCursor::Pull(Frame &frame, const SymbolTable &symbol_table) {
|
||||
if (self_.direction_ == EdgeAtom::Direction::BOTH && edge.is_cycle())
|
||||
continue;
|
||||
if (HandleExistingEdge(edge, frame, symbol_table) &&
|
||||
PullNode(edge, EdgeAtom::Direction::RIGHT, frame, symbol_table))
|
||||
PullNode(edge, EdgeAtom::Direction::OUT, frame, symbol_table))
|
||||
return true;
|
||||
else
|
||||
continue;
|
||||
@ -336,13 +336,13 @@ bool Expand::ExpandCursor::InitEdges(Frame &frame,
|
||||
}
|
||||
|
||||
auto direction = self_.direction_;
|
||||
if (direction == EdgeAtom::Direction::LEFT ||
|
||||
if (direction == EdgeAtom::Direction::IN ||
|
||||
direction == EdgeAtom::Direction::BOTH) {
|
||||
in_edges_ = std::make_unique<InEdgeT>(vertex.in());
|
||||
in_edges_it_ = std::make_unique<InEdgeIteratorT>(in_edges_->begin());
|
||||
}
|
||||
|
||||
if (direction == EdgeAtom::Direction::RIGHT ||
|
||||
if (direction == EdgeAtom::Direction::OUT ||
|
||||
direction == EdgeAtom::Direction::BOTH) {
|
||||
out_edges_ = std::make_unique<InEdgeT>(vertex.out());
|
||||
out_edges_it_ = std::make_unique<InEdgeIteratorT>(out_edges_->begin());
|
||||
@ -375,9 +375,9 @@ bool Expand::ExpandCursor::PullNode(const EdgeAccessor &new_edge,
|
||||
EdgeAtom::Direction direction, Frame &frame,
|
||||
const SymbolTable &symbol_table) {
|
||||
switch (direction) {
|
||||
case EdgeAtom::Direction::LEFT:
|
||||
case EdgeAtom::Direction::IN:
|
||||
return HandleExistingNode(new_edge.from(), frame, symbol_table);
|
||||
case EdgeAtom::Direction::RIGHT:
|
||||
case EdgeAtom::Direction::OUT:
|
||||
return HandleExistingNode(new_edge.to(), frame, symbol_table);
|
||||
case EdgeAtom::Direction::BOTH:
|
||||
permanent_fail("Must indicate exact expansion direction here");
|
||||
|
@ -750,7 +750,7 @@ TEST(CypherMainVisitorTest, RelationshipPatternDetails) {
|
||||
EXPECT_FALSE(match->where_);
|
||||
auto *edge = dynamic_cast<EdgeAtom *>(match->patterns_[0]->atoms_[1]);
|
||||
ASSERT_TRUE(edge);
|
||||
EXPECT_EQ(edge->direction_, EdgeAtom::Direction::LEFT);
|
||||
EXPECT_EQ(edge->direction_, EdgeAtom::Direction::IN);
|
||||
EXPECT_THAT(
|
||||
edge->edge_types_,
|
||||
UnorderedElementsAre(ast_generator.db_accessor_->edge_type("type1"),
|
||||
@ -777,7 +777,7 @@ TEST(CypherMainVisitorTest, RelationshipPatternVariable) {
|
||||
EXPECT_FALSE(match->where_);
|
||||
auto *edge = dynamic_cast<EdgeAtom *>(match->patterns_[0]->atoms_[1]);
|
||||
ASSERT_TRUE(edge);
|
||||
EXPECT_EQ(edge->direction_, EdgeAtom::Direction::RIGHT);
|
||||
EXPECT_EQ(edge->direction_, EdgeAtom::Direction::OUT);
|
||||
ASSERT_TRUE(edge->identifier_);
|
||||
EXPECT_THAT(edge->identifier_->name_, "var");
|
||||
EXPECT_TRUE(edge->identifier_->user_declared_);
|
||||
|
@ -132,7 +132,7 @@ TEST(QueryPlan, CreateExpand) {
|
||||
else
|
||||
symbol_table[*m->identifier_] = symbol_table.CreateSymbol("m", true);
|
||||
|
||||
auto r = EDGE("r", EdgeAtom::Direction::RIGHT);
|
||||
auto r = EDGE("r", EdgeAtom::Direction::OUT);
|
||||
symbol_table[*r->identifier_] = symbol_table.CreateSymbol("r", true);
|
||||
r->edge_types_.emplace_back(edge_type);
|
||||
r->properties_[property] = LITERAL(3);
|
||||
@ -232,7 +232,7 @@ TEST(QueryPlan, MatchCreateExpand) {
|
||||
else
|
||||
symbol_table[*m->identifier_] = symbol_table.CreateSymbol("m", true);
|
||||
|
||||
auto r = EDGE("r", EdgeAtom::Direction::RIGHT);
|
||||
auto r = EDGE("r", EdgeAtom::Direction::OUT);
|
||||
symbol_table[*r->identifier_] = symbol_table.CreateSymbol("r", true);
|
||||
r->edge_types_.emplace_back(edge_type);
|
||||
|
||||
@ -300,7 +300,7 @@ TEST(QueryPlan, Delete) {
|
||||
{
|
||||
auto n = MakeScanAll(storage, symbol_table, "n");
|
||||
auto r_m = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r",
|
||||
EdgeAtom::Direction::RIGHT, false, "m", false);
|
||||
EdgeAtom::Direction::OUT, false, "m", false);
|
||||
auto r_get = storage.Create<Identifier>("r");
|
||||
symbol_table[*r_get] = r_m.edge_sym_;
|
||||
auto delete_op = std::make_shared<plan::Delete>(
|
||||
@ -476,7 +476,7 @@ TEST(QueryPlan, SetProperty) {
|
||||
// scan (n)-[r]->(m)
|
||||
auto n = MakeScanAll(storage, symbol_table, "n");
|
||||
auto r_m = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r",
|
||||
EdgeAtom::Direction::RIGHT, false, "m", false);
|
||||
EdgeAtom::Direction::OUT, false, "m", false);
|
||||
|
||||
// set prop1 to 42 on n and r
|
||||
auto prop1 = dba->property("prop1");
|
||||
@ -527,7 +527,7 @@ TEST(QueryPlan, SetProperties) {
|
||||
// scan (n)-[r]->(m)
|
||||
auto n = MakeScanAll(storage, symbol_table, "n");
|
||||
auto r_m = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r",
|
||||
EdgeAtom::Direction::RIGHT, false, "m", false);
|
||||
EdgeAtom::Direction::OUT, false, "m", false);
|
||||
|
||||
auto op = update ? plan::SetProperties::Op::UPDATE
|
||||
: plan::SetProperties::Op::REPLACE;
|
||||
@ -630,7 +630,7 @@ TEST(QueryPlan, RemoveProperty) {
|
||||
// scan (n)-[r]->(m)
|
||||
auto n = MakeScanAll(storage, symbol_table, "n");
|
||||
auto r_m = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r",
|
||||
EdgeAtom::Direction::RIGHT, false, "m", false);
|
||||
EdgeAtom::Direction::OUT, false, "m", false);
|
||||
|
||||
auto n_p = PROPERTY_LOOKUP("n", prop1);
|
||||
symbol_table[*n_p->expression_] = n.sym_;
|
||||
|
@ -249,8 +249,8 @@ TEST(QueryPlan, Expand) {
|
||||
return PullAll(produce, *dba, symbol_table);
|
||||
};
|
||||
|
||||
EXPECT_EQ(2, test_expand(EdgeAtom::Direction::RIGHT, GraphView::AS_IS));
|
||||
EXPECT_EQ(2, test_expand(EdgeAtom::Direction::LEFT, GraphView::AS_IS));
|
||||
EXPECT_EQ(2, test_expand(EdgeAtom::Direction::OUT, GraphView::AS_IS));
|
||||
EXPECT_EQ(2, test_expand(EdgeAtom::Direction::IN, GraphView::AS_IS));
|
||||
EXPECT_EQ(4, test_expand(EdgeAtom::Direction::BOTH, GraphView::AS_IS));
|
||||
//
|
||||
// test that expand works well for both old and new graph state
|
||||
@ -259,15 +259,15 @@ TEST(QueryPlan, Expand) {
|
||||
v3.Reconstruct();
|
||||
dba->insert_edge(v1, v2, edge_type);
|
||||
dba->insert_edge(v1, v3, edge_type);
|
||||
EXPECT_EQ(2, test_expand(EdgeAtom::Direction::RIGHT, GraphView::OLD));
|
||||
EXPECT_EQ(2, test_expand(EdgeAtom::Direction::LEFT, GraphView::OLD));
|
||||
EXPECT_EQ(2, test_expand(EdgeAtom::Direction::OUT, GraphView::OLD));
|
||||
EXPECT_EQ(2, test_expand(EdgeAtom::Direction::IN, GraphView::OLD));
|
||||
EXPECT_EQ(4, test_expand(EdgeAtom::Direction::BOTH, GraphView::OLD));
|
||||
EXPECT_EQ(4, test_expand(EdgeAtom::Direction::RIGHT, GraphView::NEW));
|
||||
EXPECT_EQ(4, test_expand(EdgeAtom::Direction::LEFT, GraphView::NEW));
|
||||
EXPECT_EQ(4, test_expand(EdgeAtom::Direction::OUT, GraphView::NEW));
|
||||
EXPECT_EQ(4, test_expand(EdgeAtom::Direction::IN, GraphView::NEW));
|
||||
EXPECT_EQ(8, test_expand(EdgeAtom::Direction::BOTH, GraphView::NEW));
|
||||
dba->advance_command();
|
||||
EXPECT_EQ(4, test_expand(EdgeAtom::Direction::RIGHT, GraphView::OLD));
|
||||
EXPECT_EQ(4, test_expand(EdgeAtom::Direction::LEFT, GraphView::OLD));
|
||||
EXPECT_EQ(4, test_expand(EdgeAtom::Direction::OUT, GraphView::OLD));
|
||||
EXPECT_EQ(4, test_expand(EdgeAtom::Direction::IN, GraphView::OLD));
|
||||
EXPECT_EQ(8, test_expand(EdgeAtom::Direction::BOTH, GraphView::OLD));
|
||||
}
|
||||
|
||||
@ -294,7 +294,7 @@ TEST(QueryPlan, ExpandOptional) {
|
||||
// MATCH (n) OPTIONAL MATCH (n)-[r]->(m)
|
||||
auto n = MakeScanAll(storage, symbol_table, "n");
|
||||
auto r_m = MakeExpand(storage, symbol_table, nullptr, n.sym_, "r",
|
||||
EdgeAtom::Direction::RIGHT, false, "m", false);
|
||||
EdgeAtom::Direction::OUT, false, "m", false);
|
||||
auto optional = std::make_shared<plan::Optional>(
|
||||
n.op_, r_m.op_, std::vector<Symbol>{r_m.edge_sym_, r_m.node_sym_});
|
||||
|
||||
@ -369,7 +369,7 @@ TEST(QueryPlan, OptionalMatchEmptyDBExpandFromNode) {
|
||||
auto with = MakeProduce(optional, n_ne);
|
||||
// MATCH (n) -[r]-> (m)
|
||||
auto r_m = MakeExpand(storage, symbol_table, with, with_n_sym, "r",
|
||||
EdgeAtom::Direction::RIGHT, false, "m", false);
|
||||
EdgeAtom::Direction::OUT, false, "m", false);
|
||||
// RETURN m
|
||||
auto m_ne = NEXPR("m", IDENT("m"));
|
||||
symbol_table[*m_ne->expression_] = r_m.node_sym_;
|
||||
@ -409,7 +409,7 @@ TEST(QueryPlan, OptionalMatchThenExpandToMissingNode) {
|
||||
auto with = MakeProduce(optional, n_ne);
|
||||
// MATCH (m) -[r]-> (n)
|
||||
auto m = MakeScanAll(storage, symbol_table, "m", with);
|
||||
auto edge_direction = EdgeAtom::Direction::RIGHT;
|
||||
auto edge_direction = EdgeAtom::Direction::OUT;
|
||||
auto edge = EDGE("r", edge_direction);
|
||||
auto edge_sym = symbol_table.CreateSymbol("r", true);
|
||||
symbol_table[*edge->identifier_] = edge_sym;
|
||||
@ -494,9 +494,8 @@ TEST(QueryPlan, ExpandExistingNode) {
|
||||
|
||||
auto test_existing = [&](bool with_existing, int expected_result_count) {
|
||||
auto n = MakeScanAll(storage, symbol_table, "n");
|
||||
auto r_n =
|
||||
MakeExpand(storage, symbol_table, n.op_, n.sym_, "r",
|
||||
EdgeAtom::Direction::RIGHT, false, "n", with_existing);
|
||||
auto r_n = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r",
|
||||
EdgeAtom::Direction::OUT, false, "n", with_existing);
|
||||
if (with_existing)
|
||||
r_n.op_ =
|
||||
std::make_shared<Expand>(n.sym_, r_n.edge_sym_, r_n.edge_->direction_,
|
||||
@ -624,7 +623,7 @@ TEST(QueryPlan, EdgeFilter) {
|
||||
|
||||
auto n = MakeScanAll(storage, symbol_table, "n");
|
||||
auto r_m = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r",
|
||||
EdgeAtom::Direction::RIGHT, false, "m", false);
|
||||
EdgeAtom::Direction::OUT, false, "m", false);
|
||||
r_m.edge_->edge_types_.push_back(edge_types[0]);
|
||||
r_m.edge_->properties_[prop] = LITERAL(42);
|
||||
auto *filter_expr =
|
||||
@ -671,7 +670,7 @@ TEST(QueryPlan, EdgeFilterMultipleTypes) {
|
||||
// make a scan all
|
||||
auto n = MakeScanAll(storage, symbol_table, "n");
|
||||
auto r_m = MakeExpand(storage, symbol_table, n.op_, n.sym_, "r",
|
||||
EdgeAtom::Direction::RIGHT, false, "m", false);
|
||||
EdgeAtom::Direction::OUT, false, "m", false);
|
||||
// add an edge type filter
|
||||
r_m.edge_->edge_types_.push_back(type_1);
|
||||
r_m.edge_->edge_types_.push_back(type_2);
|
||||
@ -739,14 +738,13 @@ TEST(QueryPlan, ExpandUniquenessFilter) {
|
||||
|
||||
auto n1 = MakeScanAll(storage, symbol_table, "n1");
|
||||
auto r1_n2 = MakeExpand(storage, symbol_table, n1.op_, n1.sym_, "r1",
|
||||
EdgeAtom::Direction::RIGHT, false, "n2", false);
|
||||
EdgeAtom::Direction::OUT, false, "n2", false);
|
||||
std::shared_ptr<LogicalOperator> last_op = r1_n2.op_;
|
||||
if (vertex_uniqueness)
|
||||
last_op = std::make_shared<ExpandUniquenessFilter<VertexAccessor>>(
|
||||
last_op, r1_n2.node_sym_, std::vector<Symbol>{n1.sym_});
|
||||
auto r2_n3 =
|
||||
MakeExpand(storage, symbol_table, last_op, r1_n2.node_sym_, "r2",
|
||||
EdgeAtom::Direction::RIGHT, false, "n3", false);
|
||||
auto r2_n3 = MakeExpand(storage, symbol_table, last_op, r1_n2.node_sym_,
|
||||
"r2", EdgeAtom::Direction::OUT, false, "n3", false);
|
||||
last_op = r2_n3.op_;
|
||||
if (edge_uniqueness)
|
||||
last_op = std::make_shared<ExpandUniquenessFilter<EdgeAccessor>>(
|
||||
|
@ -250,8 +250,8 @@ TEST(TestLogicalPlanner, CreateExpand) {
|
||||
Dbms dbms;
|
||||
auto dba = dbms.active();
|
||||
auto relationship = dba->edge_type("relationship");
|
||||
QUERY(CREATE(PATTERN(NODE("n"), EDGE("r", relationship, Direction::RIGHT),
|
||||
NODE("m"))));
|
||||
QUERY(CREATE(
|
||||
PATTERN(NODE("n"), EDGE("r", relationship, Direction::OUT), NODE("m"))));
|
||||
CheckPlan(storage, ExpectCreateNode(), ExpectCreateExpand());
|
||||
}
|
||||
|
||||
@ -269,7 +269,7 @@ TEST(TestLogicalPlanner, CreateNodeExpandNode) {
|
||||
auto dba = dbms.active();
|
||||
auto relationship = dba->edge_type("rel");
|
||||
QUERY(CREATE(
|
||||
PATTERN(NODE("n"), EDGE("r", relationship, Direction::RIGHT), NODE("m")),
|
||||
PATTERN(NODE("n"), EDGE("r", relationship, Direction::OUT), NODE("m")),
|
||||
PATTERN(NODE("l"))));
|
||||
CheckPlan(storage, ExpectCreateNode(), ExpectCreateExpand(),
|
||||
ExpectCreateNode());
|
||||
@ -282,7 +282,7 @@ TEST(TestLogicalPlanner, MatchCreateExpand) {
|
||||
auto dba = dbms.active();
|
||||
auto relationship = dba->edge_type("relationship");
|
||||
QUERY(MATCH(PATTERN(NODE("n"))),
|
||||
CREATE(PATTERN(NODE("n"), EDGE("r", relationship, Direction::RIGHT),
|
||||
CREATE(PATTERN(NODE("n"), EDGE("r", relationship, Direction::OUT),
|
||||
NODE("m"))));
|
||||
CheckPlan(storage, ExpectScanAll(), ExpectCreateExpand());
|
||||
}
|
||||
@ -466,8 +466,8 @@ TEST(TestLogicalPlanner, CreateMultiExpand) {
|
||||
auto r = dba->edge_type("r");
|
||||
auto p = dba->edge_type("p");
|
||||
AstTreeStorage storage;
|
||||
QUERY(CREATE(PATTERN(NODE("n"), EDGE("r", r, Direction::RIGHT), NODE("m")),
|
||||
PATTERN(NODE("n"), EDGE("p", p, Direction::RIGHT), NODE("l"))));
|
||||
QUERY(CREATE(PATTERN(NODE("n"), EDGE("r", r, Direction::OUT), NODE("m")),
|
||||
PATTERN(NODE("n"), EDGE("p", p, Direction::OUT), NODE("l"))));
|
||||
CheckPlan(storage, ExpectCreateNode(), ExpectCreateExpand(),
|
||||
ExpectCreateExpand());
|
||||
}
|
||||
@ -529,9 +529,9 @@ TEST(TestLogicalPlanner, MatchWithCreate) {
|
||||
auto dba = dbms.active();
|
||||
auto r_type = dba->edge_type("r");
|
||||
AstTreeStorage storage;
|
||||
QUERY(MATCH(PATTERN(NODE("n"))), WITH(IDENT("n"), AS("a")),
|
||||
CREATE(PATTERN(NODE("a"), EDGE("r", r_type, Direction::RIGHT),
|
||||
NODE("b"))));
|
||||
QUERY(
|
||||
MATCH(PATTERN(NODE("n"))), WITH(IDENT("n"), AS("a")),
|
||||
CREATE(PATTERN(NODE("a"), EDGE("r", r_type, Direction::OUT), NODE("b"))));
|
||||
CheckPlan(storage, ExpectScanAll(), ExpectProduce(), ExpectCreateExpand());
|
||||
}
|
||||
|
||||
@ -604,11 +604,10 @@ TEST(TestLogicalPlanner, CreateWithOrderByWhere) {
|
||||
auto new_prop = PROPERTY_LOOKUP("new", prop);
|
||||
auto r_prop = PROPERTY_LOOKUP("r", prop);
|
||||
auto m_prop = PROPERTY_LOOKUP("m", prop);
|
||||
auto query =
|
||||
QUERY(CREATE(PATTERN(NODE("n"), EDGE("r", r_type, Direction::RIGHT),
|
||||
NODE("m"))),
|
||||
WITH(ident_n, AS("new"), ORDER_BY(new_prop, r_prop)),
|
||||
WHERE(LESS(m_prop, LITERAL(42))));
|
||||
auto query = QUERY(
|
||||
CREATE(PATTERN(NODE("n"), EDGE("r", r_type, Direction::OUT), NODE("m"))),
|
||||
WITH(ident_n, AS("new"), ORDER_BY(new_prop, r_prop)),
|
||||
WHERE(LESS(m_prop, LITERAL(42))));
|
||||
auto symbol_table = MakeSymbolTable(*query);
|
||||
// Since this is a write query, we expect to accumulate to old used symbols.
|
||||
auto acc = ExpectAccumulate({
|
||||
|
@ -179,7 +179,7 @@ TEST(TestSymbolGenerator, MatchCreateRedeclareEdge) {
|
||||
auto relationship = dba->edge_type("relationship");
|
||||
auto query = QUERY(MATCH(PATTERN(NODE("n"), EDGE("r"), NODE("m"))),
|
||||
CREATE(PATTERN(NODE("n"), EDGE("r", relationship,
|
||||
EdgeAtom::Direction::RIGHT),
|
||||
EdgeAtom::Direction::OUT),
|
||||
NODE("l"))));
|
||||
SymbolGenerator symbol_generator(symbol_table);
|
||||
EXPECT_THROW(query->Accept(symbol_generator), RedeclareVariableError);
|
||||
@ -201,7 +201,7 @@ TEST(TestSymbolGenerator, MatchCreateTypeMismatch) {
|
||||
// MATCH (n1) -[r1]- (n2) CREATE (r1) -[r2]-> (n2)
|
||||
auto query =
|
||||
QUERY(MATCH(PATTERN(NODE("n1"), EDGE("r1"), NODE("n2"))),
|
||||
CREATE(PATTERN(NODE("r1"), EDGE("r2", EdgeAtom::Direction::RIGHT),
|
||||
CREATE(PATTERN(NODE("r1"), EDGE("r2", EdgeAtom::Direction::OUT),
|
||||
NODE("n2"))));
|
||||
SymbolTable symbol_table;
|
||||
SymbolGenerator symbol_generator(symbol_table);
|
||||
@ -216,7 +216,7 @@ TEST(TestSymbolGenerator, CreateMultipleEdgeType) {
|
||||
auto dba = dbms.active();
|
||||
auto rel1 = dba->edge_type("rel1");
|
||||
auto rel2 = dba->edge_type("rel2");
|
||||
auto edge = EDGE("r", rel1, EdgeAtom::Direction::RIGHT);
|
||||
auto edge = EDGE("r", rel1, EdgeAtom::Direction::OUT);
|
||||
edge->edge_types_.emplace_back(rel2);
|
||||
auto query = QUERY(CREATE(PATTERN(NODE("n"), edge, NODE("m"))));
|
||||
SymbolTable symbol_table;
|
||||
@ -355,10 +355,10 @@ TEST(TestSymbolGenerator, CreateMultiExpand) {
|
||||
auto p_type = dba->edge_type("p");
|
||||
AstTreeStorage storage;
|
||||
auto node_n1 = NODE("n");
|
||||
auto edge_r = EDGE("r", r_type, EdgeAtom::Direction::RIGHT);
|
||||
auto edge_r = EDGE("r", r_type, EdgeAtom::Direction::OUT);
|
||||
auto node_m = NODE("m");
|
||||
auto node_n2 = NODE("n");
|
||||
auto edge_p = EDGE("p", p_type, EdgeAtom::Direction::RIGHT);
|
||||
auto edge_p = EDGE("p", p_type, EdgeAtom::Direction::OUT);
|
||||
auto node_l = NODE("l");
|
||||
auto query = QUERY(CREATE(PATTERN(node_n1, edge_r, node_m),
|
||||
PATTERN(node_n2, edge_p, node_l)));
|
||||
@ -393,7 +393,7 @@ TEST(TestSymbolGenerator, MatchCreateExpandLabel) {
|
||||
AstTreeStorage storage;
|
||||
auto query = QUERY(
|
||||
MATCH(PATTERN(NODE("n"))),
|
||||
CREATE(PATTERN(NODE("m"), EDGE("r", r_type, EdgeAtom::Direction::RIGHT),
|
||||
CREATE(PATTERN(NODE("m"), EDGE("r", r_type, EdgeAtom::Direction::OUT),
|
||||
NODE("n", label))));
|
||||
SymbolTable symbol_table;
|
||||
SymbolGenerator symbol_generator(symbol_table);
|
||||
@ -409,8 +409,8 @@ TEST(TestSymbolGenerator, CreateExpandProperty) {
|
||||
AstTreeStorage storage;
|
||||
auto n_prop = NODE("n");
|
||||
n_prop->properties_[prop] = LITERAL(42);
|
||||
auto query = QUERY(CREATE(PATTERN(
|
||||
NODE("n"), EDGE("r", r_type, EdgeAtom::Direction::RIGHT), n_prop)));
|
||||
auto query = QUERY(CREATE(
|
||||
PATTERN(NODE("n"), EDGE("r", r_type, EdgeAtom::Direction::OUT), n_prop)));
|
||||
SymbolTable symbol_table;
|
||||
SymbolGenerator symbol_generator(symbol_table);
|
||||
EXPECT_THROW(query->Accept(symbol_generator), SemanticException);
|
||||
@ -497,7 +497,7 @@ TEST(TestSymbolGenerator, CreateNodeEdge) {
|
||||
AstTreeStorage storage;
|
||||
auto node_1 = NODE("n");
|
||||
auto node_2 = NODE("n");
|
||||
auto edge = EDGE("r", r_type, EdgeAtom::Direction::RIGHT);
|
||||
auto edge = EDGE("r", r_type, EdgeAtom::Direction::OUT);
|
||||
auto node_3 = NODE("n");
|
||||
auto query = QUERY(CREATE(PATTERN(node_1), PATTERN(node_2, edge, node_3)));
|
||||
SymbolTable symbol_table;
|
||||
@ -518,7 +518,7 @@ TEST(TestSymbolGenerator, MatchWithCreate) {
|
||||
AstTreeStorage storage;
|
||||
auto node_1 = NODE("n");
|
||||
auto node_2 = NODE("m");
|
||||
auto edge = EDGE("r", r_type, EdgeAtom::Direction::RIGHT);
|
||||
auto edge = EDGE("r", r_type, EdgeAtom::Direction::OUT);
|
||||
auto node_3 = NODE("m");
|
||||
auto query = QUERY(MATCH(PATTERN(node_1)), WITH(IDENT("n"), AS("m")),
|
||||
CREATE(PATTERN(node_2, edge, node_3)));
|
||||
@ -849,7 +849,7 @@ TEST(TestSymbolGenerator, MatchMergeExpandLabel) {
|
||||
AstTreeStorage storage;
|
||||
auto query = QUERY(
|
||||
MATCH(PATTERN(NODE("n"))),
|
||||
MERGE(PATTERN(NODE("m"), EDGE("r", r_type, EdgeAtom::Direction::RIGHT),
|
||||
MERGE(PATTERN(NODE("m"), EDGE("r", r_type, EdgeAtom::Direction::OUT),
|
||||
NODE("n", label))));
|
||||
SymbolTable symbol_table;
|
||||
SymbolGenerator symbol_generator(symbol_table);
|
||||
|
Loading…
Reference in New Issue
Block a user