Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/10451#discussion_r48579121
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
---
@@ -69,6 +73,33 @@ object DefaultOptimizer extends Optimizer {
}
/**
+ * Pushes down Limit for reducing the amount of returned data.
+ *
+ * 1. Adding Extra Limit beneath the operations, including Union All.
+ * 2. Project is pushed through Limit in the rule ColumnPruning
+ *
+ * Any operator that a Limit can be pushed passed should override the
maxRows function.
+ *
+ * Note: This rule has to be done when the logical plan is stable;
+ * Otherwise, it could impact the other rules.
--- End diff --
For example, if we push `Limit` through `Filter`, `Aggregate` and
`Distinct`, the results will be wrong. For example, `df.aggregate().limit(1)`
and `df.limit(1).aggregate()`will generate the different results.
This is true iff we can push `Limit` through some operators. So far, we did
not find any eligible operators except ` outer/left-outer/right-outer Join` and
`Union`. Thus, let me revert them back. Thanks!
---
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]