GitHub user dongjoon-hyun opened a pull request: https://github.com/apache/spark/pull/13906
[SPARK-16208][SQL] Add `CollapseEmptyPlan` optimizer ## What changes were proposed in this pull request? This PR adds a new logical optimizer, `CollapseEmptyPlan`, to collapse a logical plans consisting of only empty LocalRelations. The only exceptional logical plan is aggregation. For aggregation plan, only simple cases are consider for this optimization. **Before** ```scala scala> sql("select a from values (1,2) T(a,b) where 1=0 group by a,b having a>1 order by a,b").explain == Physical Plan == *Project [a#11] +- *Sort [a#11 ASC, b#12 ASC], true, 0 +- Exchange rangepartitioning(a#11 ASC, b#12 ASC, 200) +- *HashAggregate(keys=[a#11, b#12], functions=[]) +- Exchange hashpartitioning(a#11, b#12, 200) +- *HashAggregate(keys=[a#11, b#12], functions=[]) +- LocalTableScan <empty>, [a#11, b#12] ``` **After** ```scala scala> sql("select a from values (1,2) T(a,b) where 1=0 group by a,b having a>1 order by a,b").explain == Physical Plan == LocalTableScan <empty>, [a#0] ``` ## How was this patch tested? Pass the Jenkins tests (including a new testsuite). You can merge this pull request into a Git repository by running: $ git pull https://github.com/dongjoon-hyun/spark SPARK-16208 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/13906.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #13906 ---- commit 7ddf449d39f22090bc8aa157fae12c79ba00928e Author: Dongjoon Hyun <dongj...@apache.org> Date: 2016-06-25T09:18:44Z [SPARK-16208][SQL] Add `CollapseEmptyPlan` optimizer ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org