GitHub user viirya opened a pull request: https://github.com/apache/spark/pull/17559
[SPARK-20246][SQL] Don't pushdown non-deterministic expression through Aggregate ## What changes were proposed in this pull request? import org.apache.spark.sql.functions._ val df = spark.range(1,1000).distinct.withColumn("random", rand()).filter(col("random") > 0.3).orderBy("random") The optimized plan before this: Sort [random#4 ASC NULLS FIRST], true +- Aggregate [id#0L], [id#0L, rand(-3812200341668550973) AS random#4] +- Filter (rand(-3812200341668550973) > 0.3) +- Range (1, 1000, step=1, splits=Some(2)) The optimized plan after this: Sort [random#4 ASC NULLS FIRST], true +- Filter (random#4 > 0.3) +- Aggregate [id#0L], [id#0L, rand(-6229677203478213930) AS random#4] +- Range (1, 1000, step=1, splits=Some(2)) ## How was this patch tested? Will add test later. Please review http://spark.apache.org/contributing.html before opening a pull request. You can merge this pull request into a Git repository by running: $ git pull https://github.com/viirya/spark-1 dont-pushdown-nondeter-expr-through-agg Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/17559.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 #17559 ---- commit 77896e94c854f94802d33131dc552ecb923e73ad Author: Liang-Chi Hsieh <vii...@gmail.com> Date: 2017-04-07T05:54:35Z Don't pushdown non-deterministic expression through Aggregate. ---- --- 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