From 403b7b9962d5839a09ceafeb2004336923e14b5b Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Tue, 9 Jun 2020 11:45:35 +0200 Subject: [PATCH] Enable duplicated_projection --- relational/optimizations.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/relational/optimizations.py b/relational/optimizations.py index 0c1ca08..ceca4b9 100644 --- a/relational/optimizations.py +++ b/relational/optimizations.py @@ -206,16 +206,16 @@ def down_to_unions_subtractions_intersections(n: parser.Node) -> int: return changes + recoursive_scan(down_to_unions_subtractions_intersections, n) -def duplicated_projection(n: parser.Node) -> int: +def duplicated_projection(n: parser.Node) -> Tuple[parser.Node, int]: '''This function locates thing like π i ( π j (R)) and replaces them with π i (R)''' - changes = 0 if n.name == PROJECTION and n.child.name == PROJECTION: - n.child = n.child.child - changes += 1 - - return changes + recoursive_scan(duplicated_projection, n) + return parser.Unary( + PROJECTION, + n.prop, + n.child.child), 1 + return n, 0 def selection_inside_projection(n: parser.Node) -> int: @@ -678,7 +678,7 @@ def useless_projection(n, rels) -> int: general_optimizations = [ duplicated_select, #down_to_unions_subtractions_intersections, - #duplicated_projection, + duplicated_projection, #selection_inside_projection, #subsequent_renames, #swap_rename_select,