lyne7-sc opened a new issue, #24184:
URL: https://github.com/apache/datafusion/issues/24184

   ### Describe the bug
   
   Sliding aggregate window functions can return incorrect results when a 
bounded `RANGE` frame transitions from non-empty to empty and then back to 
non-empty.
   
   The empty frame returns the correct default value, but the accumulator 
retains values from the previous frame. These stale values are included in 
subsequent results.
   
   ### To Reproduce
   
   ```sql
   SELECT k,
          SUM(v) OVER w,
          COUNT(v) OVER w,
          MIN(v) OVER w,
          MAX(v) OVER w
   FROM (VALUES
       (0, 100),
       (10, 90),
       (30, 10),
       (40, 20)
   ) AS t(k, v)
   WINDOW w AS (
       ORDER BY k
       RANGE BETWEEN 10 PRECEDING AND 5 PRECEDING
   );
   ```
   
   Current result:
   ```
   0  NULL 0 NULL NULL
   10 100  1 100  100
   30 NULL 0 NULL NULL
   40 110  2 10   100
   ```
   
   ### Expected behavior
   
   ```
   0  NULL 0 NULL NULL
   10 100  1 100  100
   30 NULL 0 NULL NULL
   40 10   1 10   10
   ```
   
   ### Additional context
   
   _No response_


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

Reply via email to