Github user marmbrus commented on a diff in the pull request: https://github.com/apache/spark/pull/10451#discussion_r48558035 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala --- @@ -153,6 +153,17 @@ object SetOperationPushDown extends Rule[LogicalPlan] with PredicateHelper { ) ) + // Adding extra Limit below UNION ALL iff both left and right childs are not Limit and no Limit + // was pushed down before. This heuristic is valid assuming there does not exist any Limit + // push-down rule that is unable to infer the value of maxRows. Any operator that a Limit can + // be pushed passed should override this function. + case Limit(exp, Union(left, right)) + if left.maxRows.isEmpty || right.maxRows.isEmpty => --- End diff -- Is there a reason to not check left and right separately?
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org