You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "viirya (via GitHub)" <gi...@apache.org> on 2023/12/04 05:52:42 UTC

Re: [PR] Update code comment for the cases of regularized RANGE frame and add tests for ORDER BY cases with RANGE frame [arrow-datafusion]

viirya commented on code in PR #8410:
URL: https://github.com/apache/arrow-datafusion/pull/8410#discussion_r1413399215


##########
datafusion/expr/src/window_frame.rs:
##########
@@ -148,18 +148,20 @@ impl WindowFrame {
 pub fn regularize(mut frame: WindowFrame, order_bys: usize) -> Result<WindowFrame> {
     if frame.units == WindowFrameUnits::Range && order_bys != 1 {
         // Normally, RANGE frames require an ORDER BY clause with exactly one
-        // column. However, an ORDER BY clause may be absent in two edge cases.
+        // column. However, an ORDER BY clause may be absent in two edge cases:
+        // 1. start bound is UNBOUNDED or CURRENT ROW
+        // 2. end bound is CURRENT ROW or UNBOUNDED.
+        // In these cases, we regularize the RANGE frame to be equivalent to a ROWS
+        // frame with the UNBOUNDED bounds.

Review Comment:
   In short, DataFusion currently allows various `ORDER BY` clause cases (empty, 1 or more column) with RANGE frame, similar to Postgres.
   
   But for empty `ORDER BY` clause case, the window function result is different to Postgres.
   
   See added tests.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org