Skip to content

Commit 3afea24

Browse files
authored
add immediate sibiling to parent op (#158)
* add imidiate sibiling to parent op * add test
1 parent 763cad5 commit 3afea24

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

redisgraph/execution_plan.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ def _create_operation(args):
164164
if op_level == level:
165165
# if the operation level equal to the current level
166166
# set the current operation and move next
167-
current = _create_operation(current_op.split("|"))
167+
child = _create_operation(current_op.split("|"))
168+
if current:
169+
current = stack.pop()
170+
current.append_child(child)
171+
current = child
168172
i += 1
169173
elif op_level == level + 1:
170174
# if the operation is child of the current operation

tests/functional/test_all.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,25 @@ def test_explain(self):
325325

326326
self.assertEqual(result.structured_plan, expected)
327327

328+
result = redis_graph.explain("""MATCH (r:Rider), (t:Team)
329+
RETURN r.name, t.name""")
330+
expected = '''\
331+
Results
332+
Project
333+
Cartesian Product
334+
Node By Label Scan | (r:Rider)
335+
Node By Label Scan | (t:Team)'''
336+
self.assertEqual(str(result), expected)
337+
338+
expected = Operation('Results') \
339+
.append_child(Operation('Project')
340+
.append_child(Operation('Cartesian Product')
341+
.append_child(Operation('Node By Label Scan'))
342+
.append_child(Operation('Node By Label Scan'))
343+
))
344+
345+
self.assertEqual(result.structured_plan, expected)
346+
328347
redis_graph.delete()
329348

330349
def test_profile(self):

0 commit comments

Comments
 (0)