Ioana Delaney created SPARK-23756:
-------------------------------------

             Summary: [Performance] Redundant join elimination
                 Key: SPARK-23756
                 URL: https://issues.apache.org/jira/browse/SPARK-23756
             Project: Spark
          Issue Type: Sub-task
          Components: SQL
    Affects Versions: 3.0.0
            Reporter: Ioana Delaney


This rewrite eliminates self-joins on unique keys. Self-joins may be introduced 
after view expansion. 

*User view:*
{code}
create view manager(mgrno, income) as 
select e.empno, e.salary + e.bonus
from employee e, department d
where e.empno = d.mgrno;
{code}

*User query:*
{code}
select e.empname, e.empno
from employee e, manager m
where e.empno = m.mgrno and m.income > 100K
{code}

*Internal query after view expansion:*

{code}
select e.lastname, e.empno
from employee e, employee m, department d
where e.empno = m.empno /* PK = PK */ and e.empno = d.mgrno and 
m.salary + m.bonus > 100K
{code}

*Internal query after join elimination:*

{code}
select e.lastname, e.empno
from employee e, department d
where e.empno = d.mgrno and 
e.salary + e.bonus > 100K
{code}




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to