From 91d6122a6e1603a894d38df189a7f6e8c7b10980 Mon Sep 17 00:00:00 2001 From: Avi Avni Date: Sun, 9 Jan 2022 16:14:26 +0200 Subject: [PATCH 1/2] add imidiate sibiling to parent op --- redisgraph/execution_plan.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 From 031786cae7af2076445f2494e5569cc8310e29d6 Mon Sep 17 00:00:00 2001 From: Avi Avni Date: Tue, 11 Jan 2022 09:07:36 +0200 Subject: [PATCH 2/2] add test --- tests/functional/test_all.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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):