[GitHub] spark pull request #14815: [SPARK-17244] Catalyst should not pushdown non-de...
Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/14815#discussion_r76512032 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala --- @@ -1385,18 +1385,25 @@ object EliminateOuterJoin extends Rule[LogicalPlan] with PredicateHelper { */ object PushPredicateThroughJoin extends Rule[LogicalPlan] with PredicateHelper { /** - * Splits join condition expressions into three categories based on the attributes required - * to evaluate them. + * Splits join condition expressions or filter predicates (on a given join's output) into three + * categories based on the attributes required to evaluate them. Note that we explicitly exclude + * on-deterministic (i.e., stateful) condition expressions in canEvaluateInLeft or --- End diff -- yea, I will :) --- 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
[GitHub] spark pull request #14815: [SPARK-17244] Catalyst should not pushdown non-de...
Github user sameeragarwal commented on a diff in the pull request: https://github.com/apache/spark/pull/14815#discussion_r76512012 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala --- @@ -1385,18 +1385,25 @@ object EliminateOuterJoin extends Rule[LogicalPlan] with PredicateHelper { */ object PushPredicateThroughJoin extends Rule[LogicalPlan] with PredicateHelper { /** - * Splits join condition expressions into three categories based on the attributes required - * to evaluate them. + * Splits join condition expressions or filter predicates (on a given join's output) into three + * categories based on the attributes required to evaluate them. Note that we explicitly exclude + * on-deterministic (i.e., stateful) condition expressions in canEvaluateInLeft or --- End diff -- good eye! can you please fold this change into one of your open PRs :) ? --- 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
[GitHub] spark pull request #14815: [SPARK-17244] Catalyst should not pushdown non-de...
Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/14815#discussion_r76511974 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala --- @@ -1385,18 +1385,25 @@ object EliminateOuterJoin extends Rule[LogicalPlan] with PredicateHelper { */ object PushPredicateThroughJoin extends Rule[LogicalPlan] with PredicateHelper { /** - * Splits join condition expressions into three categories based on the attributes required - * to evaluate them. + * Splits join condition expressions or filter predicates (on a given join's output) into three + * categories based on the attributes required to evaluate them. Note that we explicitly exclude + * on-deterministic (i.e., stateful) condition expressions in canEvaluateInLeft or --- End diff -- type: `non-deterministic` --- 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
[GitHub] spark pull request #14815: [SPARK-17244] Catalyst should not pushdown non-de...
Github user asfgit closed the pull request at: https://github.com/apache/spark/pull/14815 --- 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
[GitHub] spark pull request #14815: [SPARK-17244] Catalyst should not pushdown non-de...
Github user sameeragarwal commented on a diff in the pull request: https://github.com/apache/spark/pull/14815#discussion_r76351420 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala --- @@ -1386,15 +1386,17 @@ object EliminateOuterJoin extends Rule[LogicalPlan] with PredicateHelper { object PushPredicateThroughJoin extends Rule[LogicalPlan] with PredicateHelper { /** * Splits join condition expressions into three categories based on the attributes required - * to evaluate them. + * to evaluate them. Note that we explicitly exclude non-deterministic (i.e., stateful) condition + * expressions in canEvaluateInLeft or canEvaluateInRight to prevent pushing these predicates on + * either side of the join. * * @return (canEvaluateInLeft, canEvaluateInRight, haveToEvaluateInBoth) */ private def split(condition: Seq[Expression], left: LogicalPlan, right: LogicalPlan) = { val (leftEvaluateCondition, rest) = -condition.partition(_.references subsetOf left.outputSet) +condition.partition(expr => expr.references.subsetOf(left.outputSet) && expr.deterministic) --- End diff -- Good catch! Didn't realize that relative ordering of these expressions could become an issue. --- 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
[GitHub] spark pull request #14815: [SPARK-17244] Catalyst should not pushdown non-de...
Github user gatorsmile commented on a diff in the pull request: https://github.com/apache/spark/pull/14815#discussion_r76336122 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala --- @@ -1386,15 +1386,17 @@ object EliminateOuterJoin extends Rule[LogicalPlan] with PredicateHelper { object PushPredicateThroughJoin extends Rule[LogicalPlan] with PredicateHelper { /** * Splits join condition expressions into three categories based on the attributes required - * to evaluate them. + * to evaluate them. Note that we explicitly exclude non-deterministic (i.e., stateful) condition + * expressions in canEvaluateInLeft or canEvaluateInRight to prevent pushing these predicates on + * either side of the join. * * @return (canEvaluateInLeft, canEvaluateInRight, haveToEvaluateInBoth) */ private def split(condition: Seq[Expression], left: LogicalPlan, right: LogicalPlan) = { val (leftEvaluateCondition, rest) = -condition.partition(_.references subsetOf left.outputSet) +condition.partition(expr => expr.references.subsetOf(left.outputSet) && expr.deterministic) --- End diff -- Maybe we need to use `span` here. See another PR: https://github.com/apache/spark/pull/14012 --- 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
[GitHub] spark pull request #14815: [SPARK-17244] Catalyst should not pushdown non-de...
Github user gatorsmile commented on a diff in the pull request: https://github.com/apache/spark/pull/14815#discussion_r76334971 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala --- @@ -1386,15 +1386,17 @@ object EliminateOuterJoin extends Rule[LogicalPlan] with PredicateHelper { object PushPredicateThroughJoin extends Rule[LogicalPlan] with PredicateHelper { /** * Splits join condition expressions into three categories based on the attributes required --- End diff -- It sounds like this PR is targeting both join conditions and filter predicates. Could you update the code comment of this line and the title of the PR? --- 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
[GitHub] spark pull request #14815: [SPARK-17244] Catalyst should not pushdown non-de...
GitHub user sameeragarwal opened a pull request: https://github.com/apache/spark/pull/14815 [SPARK-17244] Catalyst should not pushdown non-deterministic join conditions ## What changes were proposed in this pull request? Given that non-deterministic expressions can be stateful, pushing them down the query plan during the optimization phase can cause incorrect behavior. This patch fixes that issue by explicitly disabling that. ## How was this patch tested? A new test in `FilterPushdownSuite` that checks catalyst behavior for both deterministic and non-deterministic join conditions. You can merge this pull request into a Git repository by running: $ git pull https://github.com/sameeragarwal/spark constraint-inputfile Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/14815.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 #14815 commit 95150970d7e5a71d9271a209a8ee453ce20f8097 Author: Sameer AgarwalDate: 2016-08-24T19:37:33Z Joins should not pushdown non-deterministic conditions commit 6728fc31bab1fd53e1005f892496ec61b6d22cd0 Author: Sameer Agarwal Date: 2016-08-25T20:45:32Z unit test --- 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