[ https://issues.apache.org/jira/browse/SPARK-22497?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Yuming Wang updated SPARK-22497: -------------------------------- Description: The below SQL will scan {{table1}} twice. We can reuse the first Project. {code:sql} with p1 as (select * from table1 where key < 100), s1 as (SELECT key, count(*) FROM p1 group by key), s2 as (SELECT key, count(*) FROM p1 where key > -100 group by key) select s1.* from s1 join s2 on s1.key= s2.key {code} was: The below SQL will scan {{table1}} twice. It can reuse the first Project. {code:sql} with p1 as (select * from table1 where key < 100), s1 as (SELECT key, count(*) FROM p1 group by key), s2 as (SELECT key, count(*) FROM p1 where key > -100 group by key) select s1.* from s1 join s2 on s1.key= s2.key {code} > Reuse project > ------------- > > Key: SPARK-22497 > URL: https://issues.apache.org/jira/browse/SPARK-22497 > Project: Spark > Issue Type: Sub-task > Components: SQL > Affects Versions: 2.3.0 > Reporter: Yuming Wang > > The below SQL will scan {{table1}} twice. We can reuse the first Project. > {code:sql} > with p1 as (select * from table1 where key < 100), > s1 as (SELECT key, count(*) FROM p1 group by key), > s2 as (SELECT key, count(*) FROM p1 where key > -100 group by key) > select s1.* from s1 join s2 on s1.key= s2.key > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org