Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/11121#discussion_r52821914
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LogicalPlan.scala
---
@@ -91,6 +91,14 @@ abstract class LogicalPlan extends
QueryPlan[LogicalPlan] with Logging {
}
/**
+ * Returns the maximum number of rows that this plan may compute.
+ *
+ * Any operator that a Limit can be pushed passed should override this
function (e.g., Union).
+ * Any operator that can push through a Limit should override this
function (e.g., Project).
+ */
+ def maxRows: Option[Expression] = None
--- End diff --
It's a `def` not a `lazy val`, I think it's fine with constant-folding
rules.
BTW using `Option[Expression]` may be sub-optimal for something like
`Union`, as its `maxRow: Some(children.flatMap(_.maxRows).reduce { (a, b) =>
Add(a, b) })` can't be constant-folded(`maxRow` is a method) and will always be
a non-literal expression, we can't push limit through it.
---
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]