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/11/25 19:34:33 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #30504: [SPARK-33544][SQL] Optimizer should not insert filter when when explode with CreateArray/CreateMap

cloud-fan commented on a change in pull request #30504:
URL: https://github.com/apache/spark/pull/30504#discussion_r530602009



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
##########
@@ -873,24 +873,30 @@ object InferFiltersFromGenerate extends Rule[LogicalPlan] {
       if !e.deterministic || e.children.forall(_.foldable) => generate
 
     case generate @ Generate(g, _, false, _, _, _) if canInferFilters(g) =>
-      // Exclude child's constraints to guarantee idempotency
-      val inferredFilters = ExpressionSet(
-        Seq(
-          GreaterThan(Size(g.children.head), Literal(0)),
-          IsNotNull(g.children.head)
-        )
-      ) -- generate.child.constraints
-
-      if (inferredFilters.nonEmpty) {
-        generate.copy(child = Filter(inferredFilters.reduce(And), generate.child))
-      } else {
-        generate
+      g.children.head match {
+        case _: CreateNonEmptyNonNullCollection =>

Review comment:
       In general, optimizer rules should be orthogonal.
   
   For this case, I think it's better to add a new optimizer rule that removes the `IsNotNull` and size check predicates above  `CreateArray` and `CreateMap`.




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