Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12147#discussion_r58430735
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/Window.scala ---
    @@ -721,16 +791,37 @@ private[execution] final class 
SlidingWindowFunctionFrame(
      */
     private[execution] final class UnboundedWindowFunctionFrame(
         target: MutableRow,
    -    processor: AggregateProcessor) extends WindowFunctionFrame {
    +    processor: AggregateProcessor,
    +    excludeSpec: ExcludeClause) extends WindowFunctionFrame {
    +
    +  // Refer to the comment below in function prepare()
    +  private[this] val buffer = new util.ArrayList[InternalRow]()
     
       /** Prepare the frame for calculating a new partition. Process all rows 
eagerly. */
       override def prepare(rows: RowBuffer): Unit = {
         val size = rows.size()
         processor.initialize(size)
    -    var i = 0
    -    while (i < size) {
    -      processor.update(rows.next())
    -      i += 1
    +    if (excludeSpec.excludeType != ExcludeNoOthers) {
    +      // For the exclude cases, the content of the window frame is always 
changing
    +      // along with the current row. For example, a row that was not 
included before
    +      // needs to be included now, or a row that was included before needs 
to be excluded now.
    +      // So intermediate buffer is used for now..
    +      // TODO: For potential performance gains, we need to look into the 
AggregateProcessor
    --- End diff --
    
    There is no way this is possible. Think of a MIN aggregate for instance. 
What you can do is merge multiple buffers.


---
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]

Reply via email to