beliefer commented on code in PR #44145:
URL: https://github.com/apache/spark/pull/44145#discussion_r1476934238
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/InferWindowGroupLimit.scala:
##########
@@ -69,10 +73,55 @@ object InferWindowGroupLimit extends Rule[LogicalPlan] with
PredicateHelper {
case _ => false
}
+ /**
+ * Whether support inferring WindowGroupLimit from Limit outside of Window.
Check if:
+ * 1. The window orderSpec exists unfoldable one or all window expressions
should use the same
+ * expanding window.
+ * 2. All window expressions should not have SizeBasedWindowFunction.
+ * 3. The Limit could not be pushed down through Window.
+ */
+ private def limitSupport(limit: Int, window: Window): Boolean =
+ limit <= conf.windowGroupLimitThreshold && window.child.maxRows.forall(_ >
limit) &&
+ !window.child.isInstanceOf[WindowGroupLimit] &&
+ (window.orderSpec.exists(!_.child.foldable) ||
+ window.windowExpressions.forall(isExpandingWindow)) &&
+ window.windowExpressions.forall {
+ case Alias(WindowExpression(windowFunction, WindowSpecDefinition(_, _,
+ SpecifiedWindowFrame(_, UnboundedPreceding, CurrentRow))), _)
+ if !windowFunction.isInstanceOf[SizeBasedWindowFunction] &&
Review Comment:
We can reuse `isExpandingWindow` here.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]