blaginin opened a new pull request, #27439:
URL: https://github.com/apache/datafusion/pull/27439

   This should fix:
   - closes https://github.com/apache/datafusion/issues/27422: Incorrect 
ordering for sliding MIN/MAX
   - closes https://github.com/apache/datafusion/issues/27267: Incorrect NULL 
placement in growing and shrinking frames
   - False monotonicity of sliding unsigned SUM
   ```sql
   SET datafusion.execution.target_partitions = 1;
   WITH t AS (
     SELECT arrow_cast(x, 'UInt32') AS x
     FROM (VALUES (1), (2), (3)) AS v(x)
   )
   SELECT SUM(x) OVER (
     ORDER BY x DESC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW
   ) AS s
   FROM t
   ORDER BY s ASC;
   ````
   - False monotonicity of sliding COUNT
   ```sql
   SELECT COUNT(x) OVER (
     ORDER BY x ASC NULLS LAST
     ROWS BETWEEN 1 PRECEDING AND CURRENT ROW
   ) AS c
   FROM (VALUES (1), (2), (CAST(NULL AS INT))) AS t(x)
   ORDER BY c ASC;
   ````
   - Per-partition ordering incorrectly treated as global ordering
   ```sql
   SELECT COUNT(*) OVER (
     PARTITION BY g ORDER BY ts
     ROWS BETWEEN 1 PRECEDING AND CURRENT ROW
   ) AS c
   FROM (VALUES (1, 1), (1, 2), (2, 3)) AS t(g, ts)
   ORDER BY c ASC;
   ```
   
   
   
   and hopefully removes an extra sort:
   
   - by partition key and `ROW_NUMBER` when the data is already in that order
   - by partition key and sliding `MIN/MAX` result
   - for sliding `MIN/MAX` results that already follow the requested order
   - for ordered `MIN/MAX` results from frames with `FOLLOWING`
   - for `FIRST_VALUE`, `LAST_VALUE`, and `NTH_VALUE` over the whole partition


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