diff --git a/relational/optimizations.py b/relational/optimizations.py index d9f15e2..7a9ee62 100644 --- a/relational/optimizations.py +++ b/relational/optimizations.py @@ -72,7 +72,7 @@ def duplicated_select(n: parser.Node) -> Tuple[parser.Node, int]: in and ''' changes = 0 - while isinstance(n, parser.UNARY) and n.name == SELECTION and isinstance(n.child, parser.UNARY) and n.child.name == SELECTION: + while isinstance(n, parser.Unary) and n.name == SELECTION and isinstance(n.child, parser.Unary) and n.child.name == SELECTION: changes += 1 prop = n.prop @@ -147,7 +147,7 @@ def down_to_unions_subtractions_intersections(n: parser.Node) -> Tuple[parser.No ''' changes = 0 _o = (UNION, DIFFERENCE, INTERSECTION) - if isinstance(n, parser.UNARY) and n.name == SELECTION and n.child.name in _o: + if isinstance(n, parser.Unary) and n.name == SELECTION and n.child.name in _o: l = parser.Unary(SELECTION, n.prop, n.child.left) r = parser.Unary(SELECTION, n.prop, n.child.right) @@ -170,7 +170,7 @@ def duplicated_projection(n: parser.Node) -> Tuple[parser.Node, int]: def selection_inside_projection(n: parser.Node) -> Tuple[parser.Node, int]: '''This function locates things like σ j (π k(R)) and converts them into π k(σ j (R))''' - if isinstance(n, parser.UNARY) and n.name == SELECTION and n.child.name == PROJECTION: + if isinstance(n, parser.Unary) and n.name == SELECTION and n.child.name == PROJECTION: child = parser.Unary( SELECTION, n.prop, @@ -338,7 +338,7 @@ def swap_rename_select(n: parser.Node) -> int: Renaming the attributes used in the selection, so the operation is still valid.''' - if isinstance(n, parser.UNARY) and n.name == SELECTION and n.child.name == RENAME: + if isinstance(n, parser.Unary) and n.name == SELECTION and n.child.name == RENAME: # This is an inverse mapping for the rename renames = {v: k for k, v in n.child.get_rename_prop().items()} @@ -438,7 +438,7 @@ def selection_and_product(n: parser.Node, rels: Dict[str, Relation]) -> parser.N σ l (σ j (R) * σ i (Q)). Where j contains only attributes belonging to R, i contains attributes belonging to Q and l contains attributes belonging to both''' - if isinstance(n, parser.UNARY) and n.name == SELECTION and n.child.name in (PRODUCT, JOIN): + if isinstance(n, parser.Unary) and n.name == SELECTION and n.child.name in (PRODUCT, JOIN): l_attr = n.child.left.result_format(rels) r_attr = n.child.right.result_format(rels)