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 2019/07/22 03:25:45 UTC

[GitHub] [spark] viirya commented on a change in pull request #25204: [SPARK-28441][SQL][Python] Fix error when PythonUDF is used in correlated scalar subquery

viirya commented on a change in pull request #25204: [SPARK-28441][SQL][Python] Fix error when PythonUDF is used in correlated scalar subquery
URL: https://github.com/apache/spark/pull/25204#discussion_r305662756
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/subquery.scala
 ##########
 @@ -318,17 +318,30 @@ object RewriteCorrelatedScalarSubquery extends Rule[LogicalPlan] {
 
   /**
    * Statically evaluate an expression containing zero or more placeholders, given a set
-   * of bindings for placeholder values.
+   * of bindings for placeholder values, if the expression is evaluable. If it is not,
+   * bind statically evaluated expression results to an expression.
    */
-  private def evalExpr(expr: Expression, bindings: Map[ExprId, Option[Any]]) : Option[Any] = {
+  private def bindingExpr(
+      expr: Expression,
+      bindings: Map[ExprId, Option[Expression]]): Option[Expression] = {
     val rewrittenExpr = expr transform {
       case r: AttributeReference =>
         bindings(r.exprId) match {
-          case Some(v) => Literal.create(v, r.dataType)
+          case Some(v) => v
           case None => Literal.default(NullType)
         }
     }
-    Option(rewrittenExpr.eval())
+    if (rewrittenExpr.find(_.isInstanceOf[PythonUDF]).isDefined) {
+      // SPARK-28441: `PythonUDF` can't be statically evaluated.
 
 Review comment:
   PythonUDF is `Unevaluable`. So you can't call `eval` on it.

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


With regards,
Apache Git Services

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