diff --git a/redisgraph/execution_plan.py b/redisgraph/execution_plan.py index 1b6b9fa..ce7bfc8 100644 --- a/redisgraph/execution_plan.py +++ b/redisgraph/execution_plan.py @@ -164,7 +164,11 @@ def _create_operation(args): if op_level == level: # if the operation level equal to the current level # set the current operation and move next - current = _create_operation(current_op.split("|")) + child = _create_operation(current_op.split("|")) + if current: + current = stack.pop() + current.append_child(child) + current = child i += 1 elif op_level == level + 1: # if the operation is child of the current operation diff --git a/tests/functional/test_all.py b/tests/functional/test_all.py index 0870507..4a51779 100644 --- a/tests/functional/test_all.py +++ b/tests/functional/test_all.py @@ -325,6 +325,25 @@ def test_explain(self): self.assertEqual(result.structured_plan, expected) + result = redis_graph.explain("""MATCH (r:Rider), (t:Team) + RETURN r.name, t.name""") + expected = '''\ +Results + Project + Cartesian Product + Node By Label Scan | (r:Rider) + Node By Label Scan | (t:Team)''' + self.assertEqual(str(result), expected) + + expected = Operation('Results') \ + .append_child(Operation('Project') + .append_child(Operation('Cartesian Product') + .append_child(Operation('Node By Label Scan')) + .append_child(Operation('Node By Label Scan')) + )) + + self.assertEqual(result.structured_plan, expected) + redis_graph.delete() def test_profile(self):