Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/10451#discussion_r48579360
--- 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 --
Below is the example. If one side has a limit child/descendant, we still
can push it down to reduce the number of returned rows.
https://github.com/gatorsmile/spark/blob/unionLimit/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/PushdownLimitsSuite.scala#L50-L57
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]