Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/9050#discussion_r41806612
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/Window.scala ---
@@ -205,14 +204,15 @@ case class Window(
*/
private[this] def createResultProjection(
expressions: Seq[Expression]): MutableProjection = {
- val unboundToAttr = expressions.map {
- e => (e, AttributeReference("windowResult", e.dataType,
e.nullable)())
+ val references = expressions.zipWithIndex.map{ case (e, i) =>
+ // Results of window expressions will be on the right side of
child's output
+ BoundReference(child.output.size + i, e.dataType, e.nullable)
}
- val unboundToAttrMap = unboundToAttr.toMap
- val patchedWindowExpression =
windowExpression.map(_.transform(unboundToAttrMap))
+ val unboundToRefMap = expressions.zip(references).toMap
+ val patchedWindowExpression =
windowExpression.map(_.transform(unboundToRefMap))
newMutableProjection(
projectList ++ patchedWindowExpression,
- child.output ++ unboundToAttr.map(_._2))()
+ child.output)()
--- End diff --
Is it true that the input row of this projection has more elements than
`child.output`? Maybe it is not very easy to understand this subtle change?
---
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]