You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/09/16 20:34:22 UTC

[GitHub] [spark] viirya opened a new pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

viirya opened a new pull request #29776:
URL: https://github.com/apache/spark/pull/29776


   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   
   This patch proposes to make GeneratePredicate eliminate common sub-expressions.
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   Both GenerateMutableProjection and GenerateUnsafeProjection, such codegen objects can eliminate common sub-expressions. But GeneratePredicate currently doesn't do it.
   
   We encounter a customer issue that a Filter pushed down through a Project causes performance issue, compared with not pushed down case. The issue is one expression used in Filter predicates are run many times. Due to the complex schema, the query nodes are not wholestage codegen, so it runs Filter.doExecute and then call GeneratePredicate. The common expression was run many time and became performance bottleneck. GeneratePredicate should be able to eliminate common sub-expressions for such case.
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   No
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   
   Unit tests.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693761084






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on a change in pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489797436



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -85,6 +85,36 @@ class CodegenExpressionCachingSuite extends SparkFunSuite {
     assert(instance2.eval(null))
   }
 
+  test("SPARK-32903: GeneratePredicate should eliminate sub-expressions") {
+    Seq(true, false).foreach { enabled =>
+      val leaf1 = ExprWithEvaluatedState()
+      val leaf2 = ExprWithEvaluatedState()
+      val leaf3 = ExprWithEvaluatedState()
+      val leaf4 = ExprWithEvaluatedState()
+
+      val expr1 = And(leaf1, leaf2)
+      val expr2 = And(leaf3, leaf4)
+      val cond = Or(expr1, expr2)
+      val instance = GeneratePredicate.generate(cond, useSubexprElimination = enabled)
+      instance.initialize(0)
+      assert(instance.eval(null) === false)
+
+      if (enabled) {
+        // When we do sub-expression elimination, Spark thought `expr1` and `expr2` are
+        // the same, so when it wants to evaluate `expr2`, it gets previous evaluation of `expr1`.

Review comment:
       This looks misleading to me because this `expr1` and `expr2` conflicts with line 95 and 96. In this context, this `expr1` and `expr2` are general ones and not referring line 95 and 96, right? If these refer the above line 95/96, the following test assertions are invalid.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] viirya commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
viirya commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693698282


   cc @cloud-fan @dongjoon-hyun 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] viirya commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
viirya commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693650230


   cc @dbtsai 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] viirya commented on a change in pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
viirya commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489792499



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -85,6 +85,36 @@ class CodegenExpressionCachingSuite extends SparkFunSuite {
     assert(instance2.eval(null))
   }
 
+  test("GeneratePredicate should eliminate sub-expressions") {

Review comment:
       Ok.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on a change in pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489797852



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -85,6 +85,36 @@ class CodegenExpressionCachingSuite extends SparkFunSuite {
     assert(instance2.eval(null))
   }
 
+  test("SPARK-32903: GeneratePredicate should eliminate sub-expressions") {
+    Seq(true, false).foreach { enabled =>
+      val leaf1 = ExprWithEvaluatedState()
+      val leaf2 = ExprWithEvaluatedState()
+      val leaf3 = ExprWithEvaluatedState()
+      val leaf4 = ExprWithEvaluatedState()
+
+      val expr1 = And(leaf1, leaf2)
+      val expr2 = And(leaf3, leaf4)
+      val cond = Or(expr1, expr2)

Review comment:
       To avoid the misleading, shall we change like this?
   ```scala
   - val expr1 = And(leaf1, leaf2)
   - val expr2 = And(leaf3, leaf4)
   - val cond = Or(expr1, expr2)
   val cond = Or(And(leaf1, leaf2), And(leaf3, leaf4))
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693753224


   **[Test build #128779 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/128779/testReport)** for PR 29776 at commit [`4dee4a9`](https://github.com/apache/spark/commit/4dee4a955b22a965ccc9e8402920c17634dce56f).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds no public classes.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693706265


   Thank you for updating, @viirya .
   cc @maropu and @kiszk , too.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] viirya commented on a change in pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
viirya commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489798557



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -85,6 +85,36 @@ class CodegenExpressionCachingSuite extends SparkFunSuite {
     assert(instance2.eval(null))
   }
 
+  test("SPARK-32903: GeneratePredicate should eliminate sub-expressions") {
+    Seq(true, false).foreach { enabled =>
+      val leaf1 = ExprWithEvaluatedState()
+      val leaf2 = ExprWithEvaluatedState()
+      val leaf3 = ExprWithEvaluatedState()
+      val leaf4 = ExprWithEvaluatedState()
+
+      val expr1 = And(leaf1, leaf2)
+      val expr2 = And(leaf3, leaf4)
+      val cond = Or(expr1, expr2)
+      val instance = GeneratePredicate.generate(cond, useSubexprElimination = enabled)
+      instance.initialize(0)
+      assert(instance.eval(null) === false)
+
+      if (enabled) {
+        // When we do sub-expression elimination, Spark thought `expr1` and `expr2` are
+        // the same, so when it wants to evaluate `expr2`, it gets previous evaluation of `expr1`.

Review comment:
       They refer to line 95/96, actually.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693653355






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693699342


   Thank you for pinging me, @viirya .


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] viirya commented on a change in pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
viirya commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489800137



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -85,6 +85,36 @@ class CodegenExpressionCachingSuite extends SparkFunSuite {
     assert(instance2.eval(null))
   }
 
+  test("SPARK-32903: GeneratePredicate should eliminate sub-expressions") {
+    Seq(true, false).foreach { enabled =>
+      val leaf1 = ExprWithEvaluatedState()
+      val leaf2 = ExprWithEvaluatedState()
+      val leaf3 = ExprWithEvaluatedState()
+      val leaf4 = ExprWithEvaluatedState()
+
+      val expr1 = And(leaf1, leaf2)
+      val expr2 = And(leaf3, leaf4)
+      val cond = Or(expr1, expr2)

Review comment:
       Yeah, sure. I put it there just for easily explanation in comment.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] kiszk commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
kiszk commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-694065130


   Sorry for coming here later. late LGTM


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-694008879


   Merged build finished. Test FAILed.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA removed a comment on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693652898


   **[Test build #128779 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/128779/testReport)** for PR 29776 at commit [`4dee4a9`](https://github.com/apache/spark/commit/4dee4a955b22a965ccc9e8402920c17634dce56f).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693705489






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on a change in pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489798488



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -85,6 +85,36 @@ class CodegenExpressionCachingSuite extends SparkFunSuite {
     assert(instance2.eval(null))
   }
 
+  test("SPARK-32903: GeneratePredicate should eliminate sub-expressions") {
+    Seq(true, false).foreach { enabled =>
+      val leaf1 = ExprWithEvaluatedState()
+      val leaf2 = ExprWithEvaluatedState()
+      val leaf3 = ExprWithEvaluatedState()
+      val leaf4 = ExprWithEvaluatedState()
+
+      val expr1 = And(leaf1, leaf2)
+      val expr2 = And(leaf3, leaf4)
+      val cond = Or(expr1, expr2)

Review comment:
       `expr1` and `expr2` is not reused in the other places.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] viirya commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
viirya commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-694328150


   Thanks @kiszk 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693653355






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693906765


   thanks, merging to master!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] maropu commented on a change in pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
maropu commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489861610



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -85,6 +85,36 @@ class CodegenExpressionCachingSuite extends SparkFunSuite {
     assert(instance2.eval(null))
   }
 

Review comment:
       Thanks!




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693761084






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] viirya commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
viirya commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693907967


   Thanks all!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693788093






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693760750


   **[Test build #128784 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/128784/testReport)** for PR 29776 at commit [`0dc312e`](https://github.com/apache/spark/commit/0dc312e3499d76d5c827e21b698aeff48db57001).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693753833






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on a change in pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489797852



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -85,6 +85,36 @@ class CodegenExpressionCachingSuite extends SparkFunSuite {
     assert(instance2.eval(null))
   }
 
+  test("SPARK-32903: GeneratePredicate should eliminate sub-expressions") {
+    Seq(true, false).foreach { enabled =>
+      val leaf1 = ExprWithEvaluatedState()
+      val leaf2 = ExprWithEvaluatedState()
+      val leaf3 = ExprWithEvaluatedState()
+      val leaf4 = ExprWithEvaluatedState()
+
+      val expr1 = And(leaf1, leaf2)
+      val expr2 = And(leaf3, leaf4)
+      val cond = Or(expr1, expr2)

Review comment:
       To avoid misleading, shall we change like this?
   ```scala
   - val expr1 = And(leaf1, leaf2)
   - val expr2 = And(leaf3, leaf4)
   - val cond = Or(expr1, expr2)
   val cond = Or(And(leaf1, leaf2), And(leaf3, leaf4))
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] maropu commented on a change in pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
maropu commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489835439



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -85,6 +85,36 @@ class CodegenExpressionCachingSuite extends SparkFunSuite {
     assert(instance2.eval(null))
   }
 
+  test("SPARK-32903: GeneratePredicate should eliminate sub-expressions") {
+    Seq(true, false).foreach { enabled =>

Review comment:
       nit: `enabled` -> `useSubexprElimination` for readability? 

##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GeneratePredicate.scala
##########
@@ -30,9 +30,17 @@ object GeneratePredicate extends CodeGenerator[Expression, BasePredicate] {
   protected def bind(in: Expression, inputSchema: Seq[Attribute]): Expression =
     BindReferences.bindReference(in, inputSchema)
 
-  protected def create(predicate: Expression): BasePredicate = {
+  def generate(expressions: Expression, useSubexprElimination: Boolean): BasePredicate =
+    create(canonicalize(expressions), useSubexprElimination)
+
+  protected def create(predicate: Expression): BasePredicate = create(predicate, false)
+
+  protected def create(predicate: Expression, useSubexprElimination: Boolean): BasePredicate = {
     val ctx = newCodeGenContext()
-    val eval = predicate.genCode(ctx)
+
+    // Do sub-expression elimination for predicates.
+    val eval = ctx.generateExpressions(Seq(predicate), useSubexprElimination)(0)

Review comment:
       nit: `useSubexprElimination)(0)` -> `useSubexprElimination).head`

##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -85,6 +85,36 @@ class CodegenExpressionCachingSuite extends SparkFunSuite {
     assert(instance2.eval(null))
   }
 

Review comment:
       Just a suggestion; Is this file a right place to add this kind of tests? Looked around the related suite files in `expressions/codegen/`, I couldn't find existing tests for common subexpr elimination in `GenerateMutableProjection` and `GenerateUnsafeProjection`. So, why don't you create a new test suite (`CodegenSubexpressionEliminationSuite` or something) and then add this test there? To improve test coverage, it might be better to add tests having the same granularity for the two projections in a separate PR.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on a change in pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489797436



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -85,6 +85,36 @@ class CodegenExpressionCachingSuite extends SparkFunSuite {
     assert(instance2.eval(null))
   }
 
+  test("SPARK-32903: GeneratePredicate should eliminate sub-expressions") {
+    Seq(true, false).foreach { enabled =>
+      val leaf1 = ExprWithEvaluatedState()
+      val leaf2 = ExprWithEvaluatedState()
+      val leaf3 = ExprWithEvaluatedState()
+      val leaf4 = ExprWithEvaluatedState()
+
+      val expr1 = And(leaf1, leaf2)
+      val expr2 = And(leaf3, leaf4)
+      val cond = Or(expr1, expr2)
+      val instance = GeneratePredicate.generate(cond, useSubexprElimination = enabled)
+      instance.initialize(0)
+      assert(instance.eval(null) === false)
+
+      if (enabled) {
+        // When we do sub-expression elimination, Spark thought `expr1` and `expr2` are
+        // the same, so when it wants to evaluate `expr2`, it gets previous evaluation of `expr1`.

Review comment:
       This looks misleading to me because this `expr1` and `expr2` conflicts with line 95 and 96. In this context, this `expr1` and `expr2` is general ones and not referring line 95 and 96, right? If these refer the above line 95/96, the following test assertions are invalid.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA removed a comment on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693705023


   **[Test build #128781 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/128781/testReport)** for PR 29776 at commit [`a0c8466`](https://github.com/apache/spark/commit/a0c84664d56c484b2e5c6a9ced966d6a77760633).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693652898


   **[Test build #128779 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/128779/testReport)** for PR 29776 at commit [`4dee4a9`](https://github.com/apache/spark/commit/4dee4a955b22a965ccc9e8402920c17634dce56f).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] viirya commented on a change in pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
viirya commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489791464



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -109,3 +139,17 @@ case class MutableExpression() extends LeafExpression with CodegenFallback {
   override def nullable: Boolean = false
   override def dataType: DataType = BooleanType
 }
+
+/**
+ * An expression with evaluated state so we can know whether it is evaluated.
+ */
+case class MutableExpression2() extends LeafExpression with CodegenFallback {

Review comment:
       OK. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693787595


   **[Test build #128781 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/128781/testReport)** for PR 29776 at commit [`a0c8466`](https://github.com/apache/spark/commit/a0c84664d56c484b2e5c6a9ced966d6a77760633).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds the following public classes _(experimental)_:
     * `case class ExprWithEvaluatedState() extends LeafExpression with CodegenFallback `


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] cloud-fan closed pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
cloud-fan closed pull request #29776:
URL: https://github.com/apache/spark/pull/29776


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693705023


   **[Test build #128781 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/128781/testReport)** for PR 29776 at commit [`a0c8466`](https://github.com/apache/spark/commit/a0c84664d56c484b2e5c6a9ced966d6a77760633).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693753833






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] viirya commented on a change in pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
viirya commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489870809



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -85,6 +85,36 @@ class CodegenExpressionCachingSuite extends SparkFunSuite {
     assert(instance2.eval(null))
   }
 
+  test("SPARK-32903: GeneratePredicate should eliminate sub-expressions") {
+    Seq(true, false).foreach { enabled =>
+      val leaf1 = ExprWithEvaluatedState()
+      val leaf2 = ExprWithEvaluatedState()
+      val leaf3 = ExprWithEvaluatedState()
+      val leaf4 = ExprWithEvaluatedState()
+
+      val expr1 = And(leaf1, leaf2)
+      val expr2 = And(leaf3, leaf4)
+      val cond = Or(expr1, expr2)

Review comment:
       Changed. And also changed the comment.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] viirya commented on a change in pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
viirya commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489861217



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -85,6 +85,36 @@ class CodegenExpressionCachingSuite extends SparkFunSuite {
     assert(instance2.eval(null))
   }
 

Review comment:
       Ok, sounds good. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693788093






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on a change in pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489788588



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -85,6 +85,36 @@ class CodegenExpressionCachingSuite extends SparkFunSuite {
     assert(instance2.eval(null))
   }
 
+  test("GeneratePredicate should eliminate sub-expressions") {

Review comment:
       Could you add `SPARK-32903: `?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-694006699


   **[Test build #128784 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/128784/testReport)** for PR 29776 at commit [`0dc312e`](https://github.com/apache/spark/commit/0dc312e3499d76d5c827e21b698aeff48db57001).
    * This patch **fails due to an unknown error code, -9**.
    * This patch merges cleanly.
    * This patch adds no public classes.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-694008879






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693705489






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-694008909


   Test FAILed.
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/128784/
   Test FAILed.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on a change in pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489791244



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -109,3 +139,17 @@ case class MutableExpression() extends LeafExpression with CodegenFallback {
   override def nullable: Boolean = false
   override def dataType: DataType = BooleanType
 }
+
+/**
+ * An expression with evaluated state so we can know whether it is evaluated.
+ */
+case class MutableExpression2() extends LeafExpression with CodegenFallback {

Review comment:
       I'm not sure, but possibly `ExpressionWithEvaluatedFlag` or something?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA removed a comment on pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #29776:
URL: https://github.com/apache/spark/pull/29776#issuecomment-693760750


   **[Test build #128784 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/128784/testReport)** for PR 29776 at commit [`0dc312e`](https://github.com/apache/spark/commit/0dc312e3499d76d5c827e21b698aeff48db57001).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on a change in pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489790080



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -109,3 +139,17 @@ case class MutableExpression() extends LeafExpression with CodegenFallback {
   override def nullable: Boolean = false
   override def dataType: DataType = BooleanType
 }
+
+/**
+ * An expression with evaluated state so we can know whether it is evaluated.
+ */
+case class MutableExpression2() extends LeafExpression with CodegenFallback {

Review comment:
       It seems that we need to give a more meaningful name instead of `MutableExpression2`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on a change in pull request #29776: [SPARK-32903][SQL] GeneratePredicate should be able to eliminate common sub-expressions

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #29776:
URL: https://github.com/apache/spark/pull/29776#discussion_r489797436



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodegenExpressionCachingSuite.scala
##########
@@ -85,6 +85,36 @@ class CodegenExpressionCachingSuite extends SparkFunSuite {
     assert(instance2.eval(null))
   }
 
+  test("SPARK-32903: GeneratePredicate should eliminate sub-expressions") {
+    Seq(true, false).foreach { enabled =>
+      val leaf1 = ExprWithEvaluatedState()
+      val leaf2 = ExprWithEvaluatedState()
+      val leaf3 = ExprWithEvaluatedState()
+      val leaf4 = ExprWithEvaluatedState()
+
+      val expr1 = And(leaf1, leaf2)
+      val expr2 = And(leaf3, leaf4)
+      val cond = Or(expr1, expr2)
+      val instance = GeneratePredicate.generate(cond, useSubexprElimination = enabled)
+      instance.initialize(0)
+      assert(instance.eval(null) === false)
+
+      if (enabled) {
+        // When we do sub-expression elimination, Spark thought `expr1` and `expr2` are
+        // the same, so when it wants to evaluate `expr2`, it gets previous evaluation of `expr1`.

Review comment:
       This looks misleading to me because this `expr1` and `expr2` conflicts with line 95 and 96. In this context, this `expr1` and `expr2` is general ones and not referring line 95 and 96, right?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org