Github user icexelloss commented on a diff in the pull request:
https://github.com/apache/spark/pull/21082#discussion_r190065854
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/planning/patterns.scala
---
@@ -268,3 +269,38 @@ object PhysicalAggregation {
case _ => None
}
}
+
+/**
+ * An extractor used when planning physical execution of a window. This
extractor outputs
+ * the window function type of the logical window.
+ *
+ * The input logical window must contain same type of window functions,
which is ensured by
+ * the rule ExtractWindowExpressions in the analyzer.
+ */
+object PhysicalWindow {
+ // windowFunctionType, windowExpression, partitionSpec, orderSpec, child
+ type ReturnType =
+ (WindowFunctionType, Seq[NamedExpression], Seq[Expression],
Seq[SortOrder], LogicalPlan)
+
+ def unapply(a: Any): Option[ReturnType] = a match {
+ case expr @ logical.Window(windowExpressions, partitionSpec,
orderSpec, child) =>
+
+ if (windowExpressions.isEmpty) {
+ throw new AnalysisException(s"Window expression is empty in $expr")
--- End diff --
I added comments to explain this.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]