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/12/05 05:04:10 UTC

[GitHub] [spark] luluorta opened a new pull request #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

luluorta opened a new pull request #30614:
URL: https://github.com/apache/spark/pull/30614


   ### What changes were proposed in this pull request?
   This PR suppresses constant folding for expressions which throw exceptions (mostly in ansi mode).
   
   
   ### Why are the changes needed?
   This PR makes the queries that have invalid expressions in unreachable branches can be executed successfully.
   
   
   ### Does this PR introduce _any_ user-facing change?
   No
   
   
   ### How was this patch tested?
   added UT + existing UTs
   


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


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


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


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


----------------------------------------------------------------
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] HyukjinKwon commented on a change in pull request #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
##########
@@ -61,8 +62,18 @@ object ConstantFolding extends Rule[LogicalPlan] {
       case Size(c: CreateMap, _) if c.children.forall(hasNoSideEffect) =>
         Literal(c.children.length / 2)
 
-      // Fold expressions that are foldable.
-      case e if e.foldable => Literal.create(e.eval(EmptyRow), e.dataType)
+      // Fold expressions that are foldable. To avoid repeatedly evaluating expressions which throw
+      // exceptions, we also check whether the expression's children are all literals.
+      case e if e.childrenToEvaluate.forall(_.isInstanceOf[Literal]) && e.foldable =>
+        val constant = try {
+          Some(e.eval(EmptyRow))

Review comment:
       I think we should do this in `Expression.foldable`. Basically if overflowing can happen, they are not foldable.




----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   **[Test build #132263 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132263/testReport)** for PR 30614 at commit [`0008f61`](https://github.com/apache/spark/commit/0008f613ff31c5164f645954935fba699990e443).
    * This patch **fails Spark unit 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] AmplabJenkins removed a comment on pull request #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


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


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


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


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   **[Test build #132261 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132261/testReport)** for PR 30614 at commit [`a7d0429`](https://github.com/apache/spark/commit/a7d0429359492b97f1c7ea7bdceb8e6a4c697214).


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


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


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   **[Test build #132499 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132499/testReport)** for PR 30614 at commit [`425290f`](https://github.com/apache/spark/commit/425290f41a583b4a5f397ef2ca3b5cc532ad5bdf).
    * This patch **fails Spark unit tests**.
    * This patch merges cleanly.
    * This patch adds the following public classes _(experimental)_:
     * `case class RaiseError(child: Expression, error: Option[Throwable] = None)`


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


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


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


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


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


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


----------------------------------------------------------------
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] HyukjinKwon commented on a change in pull request #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
##########
@@ -61,8 +62,18 @@ object ConstantFolding extends Rule[LogicalPlan] {
       case Size(c: CreateMap, _) if c.children.forall(hasNoSideEffect) =>
         Literal(c.children.length / 2)
 
-      // Fold expressions that are foldable.
-      case e if e.foldable => Literal.create(e.eval(EmptyRow), e.dataType)
+      // Fold expressions that are foldable. To avoid repeatedly evaluating expressions which throw
+      // exceptions, we also check whether the expression's children are all literals.
+      case e if e.childrenToEvaluate.forall(_.isInstanceOf[Literal]) && e.foldable =>
+        val constant = try {
+          Some(e.eval(EmptyRow))

Review comment:
       We can add it only into the expressions that can do constant folding I guess.




----------------------------------------------------------------
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 a change in pull request #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #30614:
URL: https://github.com/apache/spark/pull/30614#discussion_r537310235



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
##########
@@ -61,8 +62,18 @@ object ConstantFolding extends Rule[LogicalPlan] {
       case Size(c: CreateMap, _) if c.children.forall(hasNoSideEffect) =>
         Literal(c.children.length / 2)
 
-      // Fold expressions that are foldable.
-      case e if e.foldable => Literal.create(e.eval(EmptyRow), e.dataType)
+      // Fold expressions that are foldable. To avoid repeatedly evaluating expressions which throw
+      // exceptions, we also check whether the expression's children are all literals.
+      case e if e.childrenToEvaluate.forall(_.isInstanceOf[Literal]) && e.foldable =>
+        val constant = try {
+          Some(e.eval(EmptyRow))

Review comment:
       hmm, then it's a big perf regression for ANSI mode, as all math operations can't do constant folding.




----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


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


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


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


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


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


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   Kubernetes integration test status failure
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/36862/
   


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


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


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   **[Test build #132263 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132263/testReport)** for PR 30614 at commit [`0008f61`](https://github.com/apache/spark/commit/0008f613ff31c5164f645954935fba699990e443).


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   Kubernetes integration test status success
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/37176/
   


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/36862/
   


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   **[Test build #132499 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132499/testReport)** for PR 30614 at commit [`425290f`](https://github.com/apache/spark/commit/425290f41a583b4a5f397ef2ca3b5cc532ad5bdf).


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


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


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   **[Test build #132499 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132499/testReport)** for PR 30614 at commit [`425290f`](https://github.com/apache/spark/commit/425290f41a583b4a5f397ef2ca3b5cc532ad5bdf).


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   **[Test build #132572 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132572/testReport)** for PR 30614 at commit [`fa28948`](https://github.com/apache/spark/commit/fa28948d5672afa2f21888b043f37ef677475017).


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/37101/
   


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   **[Test build #132572 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132572/testReport)** for PR 30614 at commit [`fa28948`](https://github.com/apache/spark/commit/fa28948d5672afa2f21888b043f37ef677475017).
    * This patch **fails Spark unit 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] HyukjinKwon commented on pull request #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   cc @tgravescs too just FYI


----------------------------------------------------------------
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] luluorta commented on pull request #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   cc  @cloud-fan @leanken 


----------------------------------------------------------------
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] luluorta commented on a change in pull request #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
##########
@@ -61,8 +62,18 @@ object ConstantFolding extends Rule[LogicalPlan] {
       case Size(c: CreateMap, _) if c.children.forall(hasNoSideEffect) =>
         Literal(c.children.length / 2)
 
-      // Fold expressions that are foldable.
-      case e if e.foldable => Literal.create(e.eval(EmptyRow), e.dataType)
+      // Fold expressions that are foldable. To avoid repeatedly evaluating expressions which throw
+      // exceptions, we also check whether the expression's children are all literals.
+      case e if e.childrenToEvaluate.forall(_.isInstanceOf[Literal]) && e.foldable =>
+        val constant = try {
+          Some(e.eval(EmptyRow))

Review comment:
       According to @cloud-fan 's advice, I refactor this patch by using `RaiseError` as constant. Now we don't need to bother with the foldable expressions which can throw exceptions, cause they are still foldable and will be folded to `RaiseError`s.




----------------------------------------------------------------
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] github-actions[bot] closed pull request #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed pull request #30614:
URL: https://github.com/apache/spark/pull/30614


   


-- 
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


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


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   **[Test build #132261 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132261/testReport)** for PR 30614 at commit [`a7d0429`](https://github.com/apache/spark/commit/a7d0429359492b97f1c7ea7bdceb8e6a4c697214).
    * This patch **fails Spark unit 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] SparkQA commented on pull request #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/37176/
   


----------------------------------------------------------------
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] github-actions[bot] commented on pull request #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #30614:
URL: https://github.com/apache/spark/pull/30614#issuecomment-803695367


   We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
   If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!


-- 
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   Kubernetes integration test status success
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/37101/
   


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


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


----------------------------------------------------------------
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 a change in pull request #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #30614:
URL: https://github.com/apache/spark/pull/30614#discussion_r540737843



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/misc.scala
##########
@@ -64,38 +64,81 @@ case class PrintToStderr(child: Expression) extends UnaryExpression {
        custom error message
   """,
   since = "3.1.0")
-case class RaiseError(child: Expression) extends UnaryExpression with ImplicitCastInputTypes {
+case class RaiseError(child: Expression, error: Option[Throwable] = None)
+  extends UnaryExpression with ImplicitCastInputTypes {
+
+  def this(child: Expression) = this(child, None)
 
-  override def foldable: Boolean = false
   override def nullable: Boolean = true
   override def dataType: DataType = NullType
   override def inputTypes: Seq[AbstractDataType] = Seq(StringType)
 
   override def prettyName: String = "raise_error"
 
+  private def errorHashCode: Int = error match {
+    case Some(err) => 31 * err.getClass.hashCode() + err.getMessage.hashCode
+    case None => 0
+  }
+
+  override def hashCode(): Int = 31 * child.hashCode() + errorHashCode
+
+  private def errorEquals(other: Option[Throwable]): Boolean = (error, other) match {
+    case (Some(e), Some(o)) => e.getClass == o.getClass && e.getMessage == o.getMessage

Review comment:
       is this to skip comparing the stacktrace?




----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


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


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   **[Test build #132572 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132572/testReport)** for PR 30614 at commit [`fa28948`](https://github.com/apache/spark/commit/fa28948d5672afa2f21888b043f37ef677475017).


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   **[Test build #132263 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132263/testReport)** for PR 30614 at commit [`0008f61`](https://github.com/apache/spark/commit/0008f613ff31c5164f645954935fba699990e443).


----------------------------------------------------------------
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 #30614: [SPARK-33614][SQL] Fix the constant folding rule to skip it if the expression fails to execute

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


   **[Test build #132261 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/132261/testReport)** for PR 30614 at commit [`a7d0429`](https://github.com/apache/spark/commit/a7d0429359492b97f1c7ea7bdceb8e6a4c697214).


----------------------------------------------------------------
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