projection_and_union

master
Salvo 'LtWorf' Tomaselli 2020-06-09 19:43:56 +07:00
parent b987180d1c
commit f4a8344f3e
No known key found for this signature in database
GPG Key ID: B3A7CF0C801886CF
1 changed files with 4 additions and 15 deletions

@ -447,7 +447,7 @@ def union_and_product(n: parser.Node) -> Tuple[parser.Node, int]:
return n, 0 return n, 0
def projection_and_union(n, rels): def projection_and_union(n: parser.Node, rels: Dict[str, Relation]) -> Tuple[parser.Node, int]:
''' '''
Turns Turns
π a,b,c(A) π a,b,c(B) π a,b,c(A) π a,b,c(B)
@ -462,20 +462,9 @@ def projection_and_union(n, rels):
n.left.name == PROJECTION and \ n.left.name == PROJECTION and \
n.right.name == PROJECTION and \ n.right.name == PROJECTION and \
set(n.left.child.result_format(rels)) == set(n.right.child.result_format(rels)): set(n.left.child.result_format(rels)) == set(n.right.child.result_format(rels)):
newchild = parser.Node()
newchild.kind = parser.BINARY child = parser.Binary(UNION, n.left.child, n.right.child)
newchild.name = UNION return parser.Unary(PROJECTION, n.right.prop, child), 0
newchild.left = n.left.child
newchild.right = n.right.child
newnode = parser.Node()
newnode.child = newchild
newnode.kind = parser.UNARY
newnode.name = PROJECTION
newnode.prop = n.right.prop
replace_node(n, newnode)
changes = 1
return n, 0 return n, 0
@ -603,6 +592,6 @@ general_optimizations = [
] ]
specific_optimizations = [ specific_optimizations = [
#selection_and_product, #selection_and_product,
#projection_and_union, projection_and_union,
useless_projection, useless_projection,
] ]