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 2021/09/12 14:43:01 UTC

[GitHub] [spark] tanelk commented on a change in pull request #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should correctly infer filter for udf

tanelk commented on a change in pull request #33956:
URL: https://github.com/apache/spark/pull/33956#discussion_r706848231



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/QueryPlanConstraints.scala
##########
@@ -33,7 +33,8 @@ trait QueryPlanConstraints extends ConstraintHelper { self: LogicalPlan =>
         .union(inferAdditionalConstraints(validConstraints))
         .union(constructIsNotNullConstraints(validConstraints, output))
         .filter { c =>
-          c.references.nonEmpty && c.references.subsetOf(outputSet) && c.deterministic
+          (c.references.nonEmpty && c.references.subsetOf(outputSet) || c.references.isEmpty) &&

Review comment:
       I agree with @HyukjinKwon . In the `InferFiltersFromGenerate` we ignore expressions `e.children.forall(_.foldable)`. Unfortunatelly the `ScalaUDF` is never foldable (perhaps it could be). I would recomend turning this optimizer of, when the child expression is instance of `org.apache.spark.sql.catalyst.expressions.UserDefinedExpression`.




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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

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